Home All Groups Group Topic Archive Search About

Move folders using input from CSV



Author
17 Oct 2007 8:02 PM
Mark R.
I need to move thousands of folders (and their contents) from one location to
another. No problem if they were sequential...however, they are not. I have
an input file in CSV format (actually it's an Excel file right now) that
contains the folder names to move. I need to generate a script that will walk
through this file one line at a time and compare my source location with the
destination location. if the folder name exists in the destination the script
would move on to the next one with no changes (or even log the issue).
Example:

- moving folders from c:\test\ to d:\
- example folders in c:\test\ are:  1001, 1003, 1009, 1010, 1011 and 1015
- example folders in d:\ are:  1001, 1011 and 1015
- script should move all folders (and their contents) except for the 3 that
exist in destination
- CSV input file will have all folder names (1001, 1003, etc.) on an
individual line

Thanks!

Mark R.

Author
26 Oct 2007 4:35 AM
neothwin
Show quote
"Mark R." wrote:

> I need to move thousands of folders (and their contents) from one location to
> another. No problem if they were sequential...however, they are not. I have
> an input file in CSV format (actually it's an Excel file right now) that
> contains the folder names to move. I need to generate a script that will walk
> through this file one line at a time and compare my source location with the
> destination location. if the folder name exists in the destination the script
> would move on to the next one with no changes (or even log the issue).
> Example:
>
> - moving folders from c:\test\ to d:\
> - example folders in c:\test\ are:  1001, 1003, 1009, 1010, 1011 and 1015
> - example folders in d:\ are:  1001, 1011 and 1015
> - script should move all folders (and their contents) except for the 3 that
> exist in destination
> - CSV input file will have all folder names (1001, 1003, etc.) on an
> individual line
>
> Thanks!
>
> Mark R.


Hi Mark,

please try the batch script below with your source and destination paths.
take note on word wrapping, and there is only one command line in the batch
script. It will echo the move command to run. If the echo command display
correctly what you want, then you can edit the script by removing "@echo" and
run again.
------------------------
for /f "usebackq" %%a in (`dir c:\test\source /ad /b`) do @if not exist
c:\test\dest\%%a @echo move "c:\test\source\%%a" "c:\test\dest\"
------------------------

rgt,
neothwin

AddThis Social Bookmark Button