So basically I have a file system C:\Test\BaseLine. Under BaseLine folder I have many folders, it could be one folder or 15 folders, in those folders are image files. I want to copy all the images from INSIDE those folder NOT including BaseLine folder into another location namely C:\Test\Achieve Images with Date stamp as 03-07-2014 at the end of each image.
For example i'll have folder system like this:
BaseLine - 1.jpg, 2.jpg
->[Folder 123] - 3.jpg, 4.jpg
->[Folder 321] - 5.jpg, 6.jpg
At the end of my script i should have my C:\Test\Achieve images having these images like so:
Achieve Images - 3_03-07-2014.jpg, 4_03-07-2014.jpg, 5_03-07-2014.jpg, 6_03-07-2014.jpg
Notice how it does not include any of the BaseLine main folder images.
So far i have a script like this:
cd /d "C:\Test\BaseLine\"
@SET DATE_FOLDER=%date:~7,2%-%date:~4,2%-%date:~10,4%
SET "ACHIEVE_DIR=C:\Test\Master Achieve"
for /d %%a in ("*") do xcopy "%%a\*.*" "%ACHIEVE_DIR%\" /s/h/e/k/f/c/y
PS: This code was with the help of [user]foxidrive. Thanks again buddy for the other problem i had!!
This works but does not append the timestamp to the end of each image files Thanks!
You cannot do it with xcopy
but as you've outlined in the comments, this renames the files before copying.
The first four lines of this code will give you reliable YY DD MM YYYY HH Min Sec variables in XP Pro and higher.
@echo off
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
SET "DATE_FOLDER=%YYYY%%MM%%DD%"
cd /d "C:\Test\BaseLine\"
SET "ACHIEVE_DIR=C:\Test\Master Achieve"
md "%ACHIEVE_DIR%" 2>nul
for /d %%a in (*) do (
for /r %%b in ("%%a\*.jpg") do ren "%%~b" "%%~nb - %DATE_FOLDER%%%~xb"
xcopy "%%a\*.jpg" "%ACHIEVE_DIR%\" /s/h/e/k/f/c/y
)
pause
Edit code to move all *-tasty.jpg
files to the %ACHIEVE_DIR%
and datestamp them, then remove the original containing folders under C:\Test\BaseLine\
with all remaining files but leaving the files inside C:\Test\BaseLine\
intact.
@echo off
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
SET "DATE_FOLDER=%YYYY%%MM%%DD%"
cd /d "C:\Test\BaseLine\"
SET "ACHIEVE_DIR=C:\Test\Master Achieve"
md "%ACHIEVE_DIR%" 2>nul
for /d %%a in (*) do (
for /r %%b in ("%%a\*-tasty.jpg") do move "%%~b" "%ACHIEVE_DIR%\%%~nb - %DATE_FOLDER%%%~xb"
rd /s /q "%%a"
)
pause