cumminbk Posted October 20, 2005 Share Posted October 20, 2005 This is what i want to do. Useing a batch file check to see if a folder called "_User Backup Files\Pictures" exists If this does i want to copy the contents of that file into the My Pictures folder of my user profile. I do not want to move the entire folder and replace the My Pictures folder that is created during install i only want to copy everthing inside my "_User Backup Files\Pictures" so prob something like COPY *.* or something. If the "_User Backup Files\Pictures" folder is empty i want it to say "No backup files to copy" or something. I want to run this same command for a "_User Backup Files\Papers" folder also Does this make sense? I am haveing trouble using the IF Exist and ELSE commands and need help thankyou. Link to comment Share on other sites More sharing options...
Eki Posted October 21, 2005 Share Posted October 21, 2005 Hi! You could try something like this:@ECHO OFFSET SRC=c:\path to backup\*.*IF EXIST "%SRC%" (XCOPY "%SRC%" "%USERPROFILE%\My Documents\My Pictures" /E>nul) ELSE (ECHO No backup files to copy!)Hope this helpsEki Link to comment Share on other sites More sharing options...
Yzöwl Posted October 22, 2005 Share Posted October 22, 2005 The following may help too, it will check all your drives for you!@ECHO OFF & SETLOCAL ENABLEEXTENSIONSFOR /F %%? IN ('MOUNTVOL ^| FIND ":\"') DO CALL :CHKDRV %%?IF NOT DEFINED DCTRY ( ECHO/ No Back-ups Directory was found!) ELSE ( ECHO/ A Back-ups Directory was found at %DCTRY% XCOPY "%DCTRY%\Pictures" "%USERPROFILE%\My Documents\My Pictures" /E/H/Q/Y 2>NUL || ECHO/ No Picture Backups were found! XCOPY "%DCTRY%\Papers" "%USERPROFILE%\My Documents" /E/H/Q/Y 2>NUL || ECHO/ No Document Backups were found!)PING -n 11 127.0.0.1 >NUL & ENDLOCAL & GOTO :EOF:CHKDRVPUSHD %1 >NULFOR /F "DELIMS=" %%? IN ('DIR/B/S/AD "_USER BACKUP FILES" ^2^>NUL') DO IF ERRORLEVEL 0 SET DCTRY=%%~f?POPD & GOTO :EOF Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now