User Tools

Site Tools


Keeping your temporary documents organized

I do a lot of temporary documents: just elaborate them to send them by email, or analyze them (log files), extract conclusions (drop them in a word document) and therefore send them back by email. These things creates a lot of files that only need to be kept some days.

To save them, I developed the following method: I have a temp dir –let's say c:\temp– and inside I create a directory with the name of the date 01, 02, etc. to save temporary work in a manner more or less organized.

The problem arises when downloading files from internet or uploading files in my email client: I have always to change the location of the files: picking c:\temp\02 instead of c:\temp\01 and so one.

To solve this, I've created a tmp program. This program:

  • check for existence of the dir c:\temp\now, and if it is not found, creates it
  • if exists, check if it is older (date saved different from today's date)
  • if it is, it will be moved to the proper day (if it was created on 12/01, it will be moved to the 1 directory despite we are in 12/07)

Source code of batch file

rem @echo off
set temp=c:\temp
set destdir=c:\temp\now
set token=c:\temp\now\.token
if exist %token% goto file_exists_move_dir

rem if dir exist, skip creation and save date 
if exist %destdir% goto skip_dir_creation
mkdir %destdir%
date /t  > %token%
goto end

rem try to read content of temp\now\.token 
for /f "tokens=1,2,3 delims=/" %%i in (%token%) do set saved_day=%%i

rem read current day
for /f "tokens=1,2,3 delims=/ " %%a in ('date /t') do set cur_day=%%a
if %cur_day% == %saved_day% goto skip_renaming

rem move directory %destdir% to %saved_day%
rename %destdir% %saved_day%
goto create_dir_save_token

rem hemos acabao, abrir explorador en %destdir%
start "Explorer" "%windir%\explorer.exe" %destdir%
windows/keepingtempworkorganized.txt · Last modified: 2022/12/02 22:02 by