Remove Dirs
Moderators: Dorian (MJT support), JRL
Remove Dirs
How can i remove dirs in Macro Scheduler
Currently i use this
Let>cmdcmd=cmd /c RMDIR /S /Q %subsubdir%
Run>cmdcmd
But if the dirname is longer then 8 chars then i get a error (dos restrictions)
So now i'm wonder how can i remove dirs good and fast?
Cause something i have to remove like 200 dirs, then it runs the CMD 200 times
Currently i use this
Let>cmdcmd=cmd /c RMDIR /S /Q %subsubdir%
Run>cmdcmd
But if the dirname is longer then 8 chars then i get a error (dos restrictions)
So now i'm wonder how can i remove dirs good and fast?
Cause something i have to remove like 200 dirs, then it runs the CMD 200 times
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Did you try with quotes around %subsubdir% as JRL suggested:
Let>cmdcmd=cmd /c RMDIR /S /Q "%subsubdir%"
Let>RP_WAIT=1
Run>%cmdcmd%
Let>cmdcmd=cmd /c RMDIR /S /Q "%subsubdir%"
Let>RP_WAIT=1
Run>%cmdcmd%
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Since you seem to be in a situation where you are dealing with short file names, try this. It works on my WinXP computer.
You need to specify [drive]:\[path]\ and you may need to specify it in the short filename format.
You need to specify [drive]:\[path]\ and you may need to specify it in the short filename format.
Code: Select all
Let>RP_WAIT=1
Run>cmd /c dir "[drive]:\[path]\*.*" /ad /X /N >%TEMP_DIR%~directorylist~
Let>_counter_=0
Label>start
add>_counter_,1
ReadLn>%TEMP_DIR%~directorylist~,%_counter_%,line
If>line=##EOF##,done
If>line=,start
midstr>line,1,1,test
If>%test%=%SPACE%,start
midstr>line,53,1,test
If>%test%=.,start
midstr>line,40,1,test
If>%test%=%SPACE%
midstr>line,53,100,subsubdir
Else
midstr>line,40,12,subsubdir
EndIf
Let>test=
Let>line=
Let>cmdcmd=cmd /c RMDIR /S /Q "[drive]:\[path]\ %subsubdir%"
Run>%cmdcmd%
Goto>start
Label>done
Looking at this further I've discovered a problem with "RMDIR /S" and DOS generated short directory names. If the directory is empty RMDIR will delete it no matter how you specify the name. However if the directory is not empty "RMDIR /S will only remove the directory if you specify the full name. In other words:
A directory named C:\My Files, that contains files and/or directories, can be removed if you use the line
RMDIR /S "C:\My Files"
If that same directory has a DOS generated short file name of myfile~1 and it contains files and/or directories the line:
RMDIR /S myfile~1
will error with "The directory is not empty"
If you have a copy of "DELTREE.EXE" that shipped with Windows 95, you can use it instead of RMDIR /S. DELTREE,EXE has worked on every windows operating system since Win95. The same code from above would be ammended to:
A directory named C:\My Files, that contains files and/or directories, can be removed if you use the line
RMDIR /S "C:\My Files"
If that same directory has a DOS generated short file name of myfile~1 and it contains files and/or directories the line:
RMDIR /S myfile~1
will error with "The directory is not empty"
If you have a copy of "DELTREE.EXE" that shipped with Windows 95, you can use it instead of RMDIR /S. DELTREE,EXE has worked on every windows operating system since Win95. The same code from above would be ammended to:
Code: Select all
Let>RP_WAIT=1
Let>RP_WINDOWMODE=1
Run>cmd /c dir "[drive]:\[path]\*.*" /ad /X /N >%TEMP_DIR%~directorylist~
Let>_counter_=0
Label>start
add>_counter_,1
ReadLn>%TEMP_DIR%~directorylist~,%_counter_%,line
If>line=##EOF##,done
If>line=,start
midstr>line,1,1,test
If>%test%=%SPACE%,start
midstr>line,53,1,test
If>%test%=.,start
midstr>line,40,1,test
If>%test%=%SPACE%
midstr>line,53,100,subsubdir
Else
midstr>line,40,12,subsubdir
EndIf
Let>test=
Let>line=
Let>cmdcmd=cmd /c "[Drive]:\[Path]\deltree.exe" /Y "[Drive]:\[Path]\%subsubdir%"
Run>%cmdcmd%
Goto>start
Label>done
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Available download at: http://www.uv.tietgen.dk/staff/mlha/Dow ... S/#DELTREE
May not work on XP/2K systems with NTFS formats
Deltree NT for NTFS was available at:
http://www.freedownloadscenter.com/Util ... EE_NT.html
-----------------------
Edited 4:55 pm - The link for Deltree NT appears to be "not found". Try to google for "DELTREE NT" for alternate link....
May not work on XP/2K systems with NTFS formats
Deltree NT for NTFS was available at:
http://www.freedownloadscenter.com/Util ... EE_NT.html
-----------------------
Edited 4:55 pm - The link for Deltree NT appears to be "not found". Try to google for "DELTREE NT" for alternate link....
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!