Results 1 to 11 of 11
  1. #1
    New Lounger
    Join Date
    Apr 2016
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Batch file to move many listed files to one specific folder (A slight return)

    Many years ago DarrenMF started a thread of the same name. I'm a bit slow, I guess, but I have much the same issue.

    I have a quite a few (nearly 3000) corrupt audio files. I would like to move those corrupt files away from my collection to another drive and directory. I have located all the corrupt files and have them listed - with full file paths, one file on a line - in a text file. I would like to create a batch file that will take each file listed in that text file and move it (not just copy it) away to another place.

    Here's where I have started -

    set FILELIST=C:\Users\Ron\Desktop\FLAC_corrupt.txt [this is the text file with the list, one file per line, of the files I want to move]

    set FILESPATH=C:\Music+BU [This is the prime directory where all of my music files reside... these files are organized in many directories and sub-directories]

    set DESTPATH=F:\Corrupt_Files [this is where I want the "bad files" moved]

    After that... well, sorry guys. I haven't prepared a batch file since I moved from DOS to Windows for Workgroups. Hope someone here can help. There's no way that I am going to move this many files one at a time....

  2. #2
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,414
    Thanks
    33
    Thanked 195 Times in 175 Posts
    A couple more pieces of information are required for me:

    a) please give an example of the format of the line entries in your FILELIST file. Is each entry the full path starting with C:\Music+BU, or just relative to that folder/directory?

    b) do you want all the moved corrupt files just to appear in F:\Corrupt_Files, or should they reflect the folder/directory structure from whence they were moved?

    I am hoping you don't have any "nasty characters" in the file paths, those which cause unhappiness to BATch files...

    That said, my initial pass (with assumptions) at a BATch file would be:

    set FILELIST=C:\Users\Ron\Desktop\FLAC_corrupt.txt
    set FILESPATH=C:\Music+BU
    set DESTPATH=F:\Corrupt_Files
    for /f %%a in (%filelist%) do ECHO move "%filespath%\%%a" "%destpath%\"


    The ECHO is just to show what would happen; it should get removed when you are happy with the look of the run.

    MOVE is a particularly difficult utility to get the syntax right, by the way!
    BATcher

    Time prevents everything happening all at once...

  3. #3
    New Lounger
    Join Date
    Apr 2016
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here is an example of what is in the corrupt files list:

    C:\Music+BU\Music\Trombone Shorty\Backatown\Something Beautiful (Ft. Lenny Kravitz).flac
    C:\Music+BU\_VA\1001 Greatest 1990's Music Hit Singles\Zero - (Smashing Pumpkins).flac
    C:\Music+BU\Music\Tim McGraw\Number One Hits\2\Grown Men Don't Cry.flac
    C:\Music+BU\_VA\101 Classics\Music for Relaxing\Oboe Quartet in F Major, K. 370 - Adagio.flac
    C:\Music+BU\Music\Wanda Jackson\Unfinished Business\Two Hands.flac

    I don't need any sub-directories in the folder to which these corrupt files are moved.

  4. #4
    New Lounger
    Join Date
    Apr 2016
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Looks like the batch will stop when it encounters a space in the file name or directory. Do I need to put quotation marks before and after every one of the nearly 3000 files in my list? (I just tried putting quotation marks before and after the full file name and path in my text file, but that didn't help. Darn!)
    Last edited by rlyster; 2016-04-23 at 17:28.

  5. #5
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,186
    Thanks
    47
    Thanked 983 Times in 913 Posts
    You need to prevent the for loop splitting the files at the space. Use "tokens" to do that.

    set FILELIST=C:\Users\Ron\Desktop\FLAC_corrupt.txt
    rem set FILESPATH=C:\Music+BU
    set DESTPATH=F:\Corrupt_Files
    for /f ("tokens=*") %%a in (%filelist%) do ECHO move "%%a" "%destpath%\"


    cheers, Paul

  6. #6
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,414
    Thanks
    33
    Thanked 195 Times in 175 Posts
    Yes, that will do it - although I have never seen brackets round the "tokens=*" before!
    BATcher

    Time prevents everything happening all at once...

  7. #7
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,186
    Thanks
    47
    Thanked 983 Times in 913 Posts
    Sorry, no brackets.

    for /f "tokens=*" %%a in (%filelist%) do ECHO move "%%a" "%destpath%\"

    cheers, Paul

  8. #8
    New Lounger
    Join Date
    Apr 2016
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Close, but no cigar.

    Quote Originally Posted by Paul T View Post
    Sorry, no brackets.

    for /f "tokens=*" %%a in (%filelist%) do ECHO move "%%a" "%destpath%\"

    cheers, Paul

    Here's my result. (I have a one-file "test" file list called FLAC_corrupt_test.txt):



    C:\Users\Ron>C:\Users\Ron\Desktop\move_files.bat


    C:\Users\Ron>set FILELIST=C:\Users\Ron\Desktop\FLAC_corrupt_test.tx t


    C:\Users\Ron>rem set FILESPATH=C:\Music+BU


    C:\Users\Ron>set DESTPATH=F:\Corrupt_Files


    C:\Users\Ron>for /F "tokens=*" %a in (C:\Users\Ron\Desktop\FLAC_corrupt_test.txt
    ) do ECHO move "%a" "F:\Corrupt_Files\"


    C:\Users\Ron>ECHO move "C:\Music+BU\Music\Alan Stivell\Live in Dublin\Pachpi Koz
    h Pachpi New.flac" "F:\Corrupt_Files\"
    move "C:\Music+BU\Music\Alan Stivell\Live in Dublin\Pachpi Kozh Pachpi New.flac"
    "F:\Corrupt_Files\"


    Looks good, but nothing was moved.

  9. #9
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Remove the "ECHO" from the last command to have it perform the move. HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  10. #10
    New Lounger
    Join Date
    Apr 2016
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    YES! That worked! Thank you guys!

  11. #11
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,414
    Thanks
    33
    Thanked 195 Times in 175 Posts
    Excellent!
    BATcher

    Time prevents everything happening all at once...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •