Moving specific files from a folder

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Mithun.dsouza
Posts: 3
Joined: 26 Jun 2011 21:51

Moving specific files from a folder

#1 Post by Mithun.dsouza » 26 Jun 2011 22:01

Hey guys
Need some help with a batch script that will allow me to move a specific number of files in a loop to a created new folder structure following an excel file which specifics the new folder number append (. 1,2,3,4,5,6,7...) and in the second column has the corresponding number of frames to be moved (121,100,44,33...).

The syntax of the file names are the same, just with the number of cell padding recursively increasing
Eg:
another000001.dpx, another000002.dpx, another000003.dpx etc

The first generated folder should have a name like Shot1 and 121 files should be moved to the new folder reading from the excel
The second folder should be named Shot2 and 100 files should be moved to the new folder from the top reading from the excel
And so on...

Someone help?

Acy Forsythe
Posts: 126
Joined: 10 Jun 2011 10:30

Re: Moving specific files from a folder

#2 Post by Acy Forsythe » 27 Jun 2011 07:45

Is the Excel file saved as a CSV file?

Or is it a .XLS file? If so can it be saved as a CSV file?

Does the first row have headers?

Can you post an example of the XLS file?

Mithun.dsouza
Posts: 3
Joined: 26 Jun 2011 21:51

Re: Moving specific files from a folder

#3 Post by Mithun.dsouza » 27 Jun 2011 14:11

Unfortunately onthe iPad right now
Here's a copy paste fromthe xls

01:00:00:00 01:00:05:01 121
01:00:05:01 01:00:09:05 100
01:00:09:05 01:00:18:18 229
01:00:18:18 01:00:20:17 47
01:00:20:17 01:00:22:16 47
01:00:22:16 01:00:24:14 46
01:00:24:14 01:00:26:02 36
01:00:26:02 01:00:29:06 76
01:00:29:06 01:00:31:21 63
01:00:31:21 01:00:37:21 144
01:00:37:21 01:00:47:10 229
01:00:47:10 01:00:49:18 56
01:00:49:18 01:00:58:00 198
01:00:58:00 01:01:04:02 146
01:01:04:02 01:01:12:05 195
01:01:12:05 01:01:18:04 143
01:01:18:04 01:01:21:04 72
01:01:21:04 01:01:23:16 60
01:01:23:16 01:01:28:21 125
01:01:28:21 01:01:35:13 160
01:01:35:13 01:01:49:15 338
01:01:49:15 01:01:54:06 111
01:01:54:06 01:01:55:16 34
01:01:55:16 01:01:56:16 24
01:01:56:16 01:02:01:07 111

First coloum has in Timecode
Second has out
Third has number of frames

It's an xls file for now, but I might be able to save as a csv

Thanks :)

Acy Forsythe
Posts: 126
Joined: 10 Jun 2011 10:30

Re: Moving specific files from a folder

#4 Post by Acy Forsythe » 27 Jun 2011 16:23

Just a few more questions...

Where are you copying the files from?

Where do you get the destination directory name (IE \Shot in your example, or \Shot1 \Shot2, where do you get the "Shot" portion from?)

Same question with the filenames, where do you get the "another" part from?

If you know anything about batch scripting, then you should be able to follow this process... Provided you can save in CSV format:

Code: Select all

@Echo OFF
setlocal enabledelayedexpansion

Set FolderCount=1

FOR /F "tokens=1-3 delims=," %%a IN (Path to CSV file) DO (
 MkDIR Pathtonewfolder!FolderCount!


  FOR /L %%A IN (1,1,%%c) DO (
     COPY Pathtoexistingfiles\filename%%A.ext Pathtonewfolder!FolderCount!\filename%%A.ext
   )
 Set /A FolderCount+=!FolderCount!
)

exit /b


If you can answer the questions I have, I can probably fill in the Pseudo paths in my code for you...

Mithun.dsouza
Posts: 3
Joined: 26 Jun 2011 21:51

Re: Moving specific files from a folder

#5 Post by Mithun.dsouza » 27 Jun 2011 21:57

For the input directory (source folder), I was hoping I could input that into the prompt in the batch script.
The files will just need to be moved (not copied) from the source to the generated destination shot folders.
An input can be triggered in the prompt for the destination directory as well.
The new folders can be called Shot1, Shot2, Shot3, etc recursively.

The file names don't need to be changed considering the files are just being moved from source to destination folders.
In my example, no matter what the folder contents are, the script should readnthe csv and then

Move shots 1 - 121 to a new folder called Shot1
Move shots 122 - 222 to a new folder called Shot2
And so on

Hope this clears things out.
My coding knowledge is next to non-existent. So its all over mynhead honestly :(
But thanks so much for taking the time off to help and reply :)

Post Reply