@JasonLLINDNER
The above code has been designated with pause just to make sure no errors occured and the /-y is a security so that IF a file with the same name exists in the destination folder; it will prompt user to enter one of the following option (manually): Y (Yes); Overwrite – single file when prompted; N (No); Do not overwrite; A (All); Overwrite all files
If you are sure you want to overwrite existing files and certain that you don't want to see the CMD Prompt window or any possible errors; you need to
- replace /-y with /y to overwrite all files without prompting
- add @echo OFF as first line to run the command in the background without opening CMD Prompt window
- Remove the Pause at the end; this will close CMD Prompt window straight after the move command is executed. (Originally placed to allow user to see any errors before window closes)
@echo Off
move /y "C:\Project_Folder_Location\*.00*.rvt" "C:\BACKUP_Folder_Location"
PS: if you really want to execute it in the background, I would suggest the following:
- First rename current backup file and add the date YYYYMMDD to its file name (ex: rename Practice_001.0006.rvt to Practice_001.0006.BKUP_20160410.rvt)
- keep the /-y in the move command (just in case! to make sure no file gets overwritten arbitrarily)
- add cleanup command that checks and deletes revit backup files older than 30 days in the backup folder and its subfolders
@echo off
rem Command renames backup files and adds BKUP_YYYYMMDD to files' name
ren "C:\Users\MINIJODA\Desktop\RVT PROJECT\*.00*.rvt" "*.BKUP_%date:~10,4%%date:~4,2%%date:~7,2%.rvt
goto Move
:Move
rem moves renamed backup files
move /-y "C:\Users\MINIJODA\Desktop\RVT PROJECT\*.00*.rvt" "C:\Users\MINIJODA\Desktop\RVT BACKUP"
goto 30DaysCleanup
:30DaysCleanup
rem deletes all .rvt files older than 30 days in the specified path including those in subfolders
rem forfiles [/p <Path>] [/m <SearchMask>] [/s] [/c "<Command>"] [/d [{+|-}][{<Date>|<Days>}]]
forfiles /p "C:\Users\MINIJODA\Desktop\RVT BACKUP" /s /m *.rvt /d -30 /c "cmd /c del @PATH"
NOTE:
- all line with rem are remarks (ie: can be deleted)
- the cleanup line deletes files permenantly (ie: NOT to Recycle Bin)
- file RevitBKUP.txt attached ... download and rename to RevitBKUP.bat
- don't forget to change the paths to suit your folder structure 😛
Enjoy