RMDIR - "The system cannot find the path specified."

kanfaar

Thread Starter
Joined
Aug 18, 2011
Messages
166
If you don't want the background, please skip to the 'rmdir' portion below:

I have a scheduled task running some VBScript running a snapshot backup process.Two scripts run: 1) Renames the first <FolderName> on the <LinuxNAS> to an even longer name <FolderName Temp01> in order to get it out of the way so it can copy the backup files to a new folder named <FolderName>. Later that night, there's a second process which comes in and looks for folders named <FolderName Temp##> and deletes them. (Part of the trouble here is that the user is remote and the delete process can run 12+ hours, so they frequently ended up interrupting the deletion process, so I needed to get the copy done first, then worry about deletions. I run the deletions on a machine local to the NAS which speeds it up tremendously.)

Originally, I mapped drives to the source and target folders so I worry less on whose computer it's running, meaning the mapping is a hold-over from the original code, partially in place to reduce the characters needed to reference the filename(s). But, it's the Drive Letter (H: mapped to "\\<LinuxNAS>\<UserName>\"
(EDIT: H: was coming up as an emoji since I had the following "\")

RMDIR: The pseudo-command below is what's being run:

rmdir /S /Q H:\FolderName Temp01

RETURNS:

H:\FolderName Temp01\P3KBJB~5\Local\Jobs\MMoA-01\Pages\26WEX3~4 - The system cannot find the path specified.
H:\FolderName Temp01\P3KBJB~5\Local\Jobs\MMoA-01\Pages\A4G8OS~C - The system cannot find the path specified.
H:\FolderName Temp01\P3KBJB~5\Local\Jobs\MMoA-01\Pages\A06RBP~V - The system cannot find the path specified.

(etc, etc, etc, many thousands of times)

ACTUAL FILENAMES:
H:\FolderName Temp01\PlanSwift\Local\Jobs\MMoA-01\Pages\2020-02-27 METAL PAN
H:\FolderName Temp01\PlanSwift\Local\Jobs\MMoA-01\Pages\A0.00 COVER SHEET
H:\FolderName Temp01\PlanSwift\Local\Jobs\MMoA-01\Pages\A0.01 DRAWING INDEX

(etc, etc, etc, many thousands of times)

FILENAMES: If you notice, there are tildes in the sub-foldernames. Interestingly the parent folder DOESN'T... I have confirmed, the following:

These are the short names for their respective folders
The overall lengths of the filenames (without the shortnames) never exceeds 200 chars, Even if I substitute the full path instead of the drive letter.
There are no special characters in any of the filenames, except those that generally don't cause trouble (like "+", "-", "_" - less the quotes).
Not all filenames include the 'safe' special characters, so even that's covered.

OPTIONS:

I can delete the folder in any myriad of ways, from right-click > Delete, to dragging it to the recycle bin, to pressing the delete key....permissions is not the trouble.

SERVER:

This is a Linux-based NAS that you may want to point to as the source of the trouble, but (and this MAY be key here) it's only happening with the remote user. There are two other users whose files are targeted by this same code and they never have any troubles. It is a WD My Cloud EX4100, no info on the precise OS, but I'm sure it's some open-source stuff pilfered by WD for re-sale >:-( I Digress...

This is lengthy and I apologize for that. It's just that these types of posts are frequently (DARN-NEAR-ALWAYS!!!) misunderstood and there's more time spent getting across exactly what the trouble is when assumptions are made about the problem. So, I try to explain as much as I can in advance of the misunderstanding.
 
Last edited:
Joined
Mar 2, 2019
Messages
897
Instead of:
rmdir /S /Q H:\FolderName Temp01

run
rmdir /S /Q "H:\FolderName Temp01"

In Administrative (elevated) command prompt (not powershell)

If not working:
right click folder, properties, and take ownership of directory tree and files, in addition to ownership take full permissions of entry tree and files. then try again.
 

kanfaar

Thread Starter
Joined
Aug 18, 2011
Messages
166
Thank you for the reply. Turns out the quotes are already there; when I pasted the command to the forum, it was a sea of quotes because it also uses variables. When I pared it down, I got rid of too many quotes. Here's the actual code:

sso.Run "%comspec% /c rmdir /S /Q """ & strTmpDrv(DriveNo) & "\" & FolderName & """ 2>>""" & ErrorFile & """", DontShowWindow, WaitToFinish

Also, permissions are not the trouble: I can delete the file(s) in any myriad of ways (and it works with the other users' files) As mentioned previously, I suspect the short filenames since this is the only user whose files resolve thus. I could easily be wrong though, since I can't fix it.

I'm 99.99965% positive it's not the quotes, though.
 
Joined
Mar 2, 2019
Messages
897
I'm not expert with batch files, this could be done much better with powershell, but your command doesn't look right to me (I could be wrong).

It should probably be something like:
sso.Run "%comspec% /c "rmdir /S /Q """ & strTmpDrv(DriveNo) & "\" & FolderName & """" 2>>""" & ErrorFile & """", DontShowWindow, WaitToFinish

The point is to enclose rmdir and path into new quotes since the path could contain empty spaces.
 

kanfaar

Thread Starter
Joined
Aug 18, 2011
Messages
166
Thanks again for the follow-up. I appreciate the effort, but I'm not receiving any error on the command itself. It's running the rmdir command, that's not a problem. As mentioned previously, it runs fine. There's nothing wrong with the command. It's not permissions. It's not how the quotes are set-up.

By the way, it's not a batch file, it's VBScript...similar but more powerful.

I'm trying to get at the root of the trouble and why it's interpreting the filenames as short-names and not as the long names they actually are. You're looking for problems in the command(s). That's why I didn't want to post any more than absolutely necessary, because the script has been solid for over a year; it remains solid. You may be able to debug it and find some inefficiencies, but it works. Except for this one case. It says it can't find folders of the name P3KBJB~5 Technically, that file exists, but it's the short name of "PlanSwift". I can run a DIR of P3KBJB~5 but RMDIR won't delete it. That's it...
 

kanfaar

Thread Starter
Joined
Aug 18, 2011
Messages
166
I agree, not sure either. Something is up with it though and I don't understand it. I was able to get the script to delete the files regardless, now it's just a mystery. Problem is not solved because don't know why it was failing. Program works around it now, so it'll probably fade as it continues to be unanswered...hate that. Thanks for trying.
(edit: Thanks is not spelled 'thqnks')
 

Users Who Are Viewing This Thread (Users: 0, Guests: 2)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top