You are not logged in.
Pages: 1
I need to do this advanced sub-directory sorting process which is risky.
There is a folder which has sub-directories, whenever a different person uses the script, it needs to rename this sub-directory. The oldest sub-directory has all the stuff in it.
Everytime the script runs (Not sub-directories of sub-directories, just the top sub-directories)
a) the oldest sub-directory must be renamed according to the script
b) the other sub-directories must be deleted
The challenge is
a) if there is no other sub-directories while the script runs
b) if there are sub-directories while the script runs
c) not to delete this sub-directory
:UPDATING2
CD /D "%GAMEDIR%\SteamApps"
MD safe
FOR /F "TOKENS=*" %%G IN ('DIR/B /AD /O-D') DO SET FOLDER=%%G
REN "%FOLDER%" "%USERKEY%"
:USERFOLDER
FOR /F "TOKENS=*" %%G IN ('DIR/B /AD /OD') DO SET FOLDER=%%G
SET FOLDER="%FOLDER%"
IF "%USERKEY%"==%FOLDER% GOTO LAUNCHER
SET FOLDER=%FOLDER:~1,-1%
RD "%FOLDER%"
GOTO USERFOLDER
This is the current code, which only works when there is no other sub-directories, however if there are other sub-directories, it goes into an endless loop.
Suggestions?
cmd, vbs, ps, bash
autoit, python, swift
Offline
I think I would approach this by first moving the oldest folder to completley different area
next delete all the other sub folders
lastly move the folder back, changing the name as needed
Perhaps the reason your script failed is that the rename turns the oldest folder into the newest folder?
Offline
Pages: 1