Created
September 26, 2013 21:46
-
-
Save ricardoparro/6721056 to your computer and use it in GitHub Desktop.
file manipulator - windows batch script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo on | |
setlocal enabledelayedexpansion | |
rem this first iteration grabs all ok files and copy them to the destination | |
for /F %%i in ('dir C:\robocopyTest\source /s /b') do ( | |
Set originalFileName=%%~ni | |
Set prefix=!originalFileName:~0,3! | |
if !prefix! == OK_ ( | |
XCOPY "%%i" C:\robocopyTest\destination /Y | |
) | |
) | |
rem this grabs all ok files on destination and change the name of all files | |
for /F %%f in ('dir C:\robocopyTest\destination /s /b') do ( | |
set oldname= %%~nf | |
set newname=!oldname:~4! | |
ren "%%f" "!newname!.pdf" | |
) | |
for /F "tokens=*" %%b in ('dir C:\robocopyTest\source /s /b') do ( | |
Set originalSourceFileName=%%~nb | |
Set exists = "false" | |
for /F %%g in ('dir C:\robocopyTest\destination /s /b') do ( | |
Set destinationSourceFileName=%%~ng | |
pause | |
if !destinationSourceFileName! == !originalSourceFileName! ( | |
pause | |
Set exists ="true" | |
) | |
) | |
if !exists! == "false" ( | |
XCOPY "%%b" C:\robocopyTest\destination /Y | |
) | |
) | |
pause | |
::FOR /F "tokens=*" %%i in ('dir C:\Projects /AD /s /b') DO ( | |
::echo "%%i" | |
::REM XCOPY "%%i\*.jpg" C:\robocopyTest /Y | |
::) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment