Computer Guy
asked on
I need to move some Folders
Hi,
How can I all at once move the folders (+ files in the folders) in the "From" folder, to the "To" folder.
02 is the month
2014 is the year
These values will change every month and year.
I am open to any technology/method, and a commercial solution is OK. - Any suggestions would be grateful!!
From: W:\WOW HITS - 02-2014
To: W:\Vid\WOW HITS\WOW HITS 2014\
From: W:\HOT MOVIE CLASSICS - 02-2014
To: W:\Vid\HOT MOVIE CLASSICS\HOT MOVIE CLASSICS 2014\
From: W:\AMBIENT VIDEO 02-14
To: W:\Vid\AMBIENT VIDEO\AMBIENT VIDEO 2014\
How can I all at once move the folders (+ files in the folders) in the "From" folder, to the "To" folder.
02 is the month
2014 is the year
These values will change every month and year.
I am open to any technology/method, and a commercial solution is OK. - Any suggestions would be grateful!!
From: W:\WOW HITS - 02-2014
To: W:\Vid\WOW HITS\WOW HITS 2014\
From: W:\HOT MOVIE CLASSICS - 02-2014
To: W:\Vid\HOT MOVIE CLASSICS\HOT MOVIE CLASSICS 2014\
From: W:\AMBIENT VIDEO 02-14
To: W:\Vid\AMBIENT VIDEO\AMBIENT VIDEO 2014\
And, was this a typo or does this one really only use a two digit year?
From: W:\AMBIENT VIDEO 02-14
or should it match the others like:
From: W:\AMBIENT VIDEO - 02-2014
~bp
From: W:\AMBIENT VIDEO 02-14
or should it match the others like:
From: W:\AMBIENT VIDEO - 02-2014
~bp
ASKER
Haha. Typo. Year is suppose to be 4 digits and month 2. Good eye!!
Okay, here is a starting point assuming a typo in the examples, and assuming you hard code the month and year into the script. This can easily be adjusted to either take them as a command line parameter, or get them from the current date, or maybe a combo.
Save as a BAT file, adjust the paths as needed, and do some testing...
Save as a BAT file, adjust the paths as needed, and do some testing...
@echo off
setlocal EnableDelayedExpansion
set MM=02
set YYYY=2014
REM Define folder locations (no trailing "\")
REM set BaseDir=W:
REM set DestDir=W:\Vid
set Folders="WOW HITS","HOT MOVIE CLASSICS","AMBIENT VIDEO"
REM Process each folder name to process
for %%A in (%Folders%) do (
REM If the source folder doesn't exist (with month and year added) report as error
if not exist "%BaseDir%\%%~A - %MM%-%YYYY%\" (
echo *WARNING* Folder [%BaseDir%\%%~A - %MM%-%YYYY%] does not exist, skipped.
) else (
REM If dest folder does not exist (with year added) create it
if not exist "%DestDir%\%%~A\%%~A %YYYY%\" (
md "%DestDir%\%%~A\%%~A %YYYY%\"
)
REM Move entire source folder to dest folder
move "%BaseDir%\%%~A - %MM%-%YYYY%" "%DestDir%\%%~A\%%~A %YYYY%\" > NUL
)
)
~bp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
~bp