Skip to main content

Posts

Showing posts with the label CMD

Move Old Files to an Archive Folder

I have a folders structure where I store my scripts, backups, documents as shown below The folders becomes cluttered with old versions of the files. So I decided to create a script that will move old files from each of the folders beneath the root one (e.g., C:\WP) to an archive sub-folder (if it exists at the particular level). So I decided to archive old files in the Backups, Exchange, and SharePoint folders. I created sub-folders called 'ARCHIVE' under each of those three folders as shown below And then I created the following batch file @ECHO OFF SETLOCAL SET ArchiveFolder=Archive SET OlderThan=2 SET Extensions=TXT CSV BAK LOG REM starts from the current folder  REM   [when it's a scheduled task this is configured as "START IN"] REM CD C:\WP SET debug=ECHO  SET LogFile="%~dpn0.LOG" FOR /F %%m in ('CD') Do SET StartDir=%%m %debug%.>>%LogFile% %debug%.>>%LogFile% %debug%.>>%LogFile% %debug%...