Click here to Skip to main content
15,851,131 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Due to some user misbehaving I have now a Windows 10 pc where several files/folders have quite long names, and containing Unicode chars in a folder structure very deep (>10 levels)
The problem is that even after applying "LongPathsEnabled" enabled using vbscript I can't rename all those files/folders.
The .Getfolder of FileSystemObject keeps gettin "Path not found".
I was able to overcome the problem using a Robocopy "/MOVE" inside a shell, but this has another problem: some folder is quite big so it will take a long time to "MOVE" (=rename) that folder.
I'm stuck here. Anyone can help pointing me in the correct directions, maybe some way to use API inside vbscript?
Thanks
Luigi

What I have tried:

As previously described I did some test whit vbscript shell and robocpy.
Posted
Updated 4-Aug-23 23:40pm
Comments
Member 15627495 5-Aug-23 2:15am    
there are not better resources like the 'Path' class to handle Paths.

"Path not found" is for unreachable Paths.
if you encount a too long Path, the error will be different.

Thanks for the details about your aim and those bug.

but some code will be more interisting for debug.

Paths are String , but they are 'UNC' too.
https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats

Not my expertise in the least but I found this very interesting. Some research later I found the following, whether it will solve your issue completely, I am not sure but it might point you in the right direction.

First of all, a warning from most articles and posts -
Quote:
Before performing any mass-renaming operations, make sure you have a backup of the data to avoid accidental data loss.


Some 3rd party tools I found that seesm to work with long file names etc -
1) Long Path Tool[^]
Quote:
The most user-friendly long path files problem fixer for Windows and Mac. Delete, copy, bulk rename long path files.


2) Total Commander[^]
Quote:
Total Commander is a file manager replacement that offers multiple language support, search, file comparison, directory synchronization, quick view panel with bitmap display, ZIP, ARJ, LZH, RAR, UC2, TAR, GZ, CAB, ACE archive handling plus plugins, built-in FTP client with FXP, HTTP proxy support, and more.


3) FastCopy[^]
Quote:
FastCopy is the Fastest Copy/Backup Software on Windows
It supports UNICODE and over MAX_PATH (260 characters) file pathnames.
Because it uses multi-threads for Read/Write/Verify, Overlapped I/O, Direct I/O, so it brings out the best speed of devices.
It supports Include/Exclude filter like a UNIX wildcard.
It runs fast and does not hog resources, because MFC is not used.


Use the 'subst' command which allows you to create a virtual drive letter that points to a specific folder path. By doing this, you can access the problematic folder with a shorter path to make handling it much easier - MS Learn | subst command[^]

In your cmd, run -
subst X: "C:\very\long\path\to\your\problematic\folder"


I see you used Robocopy already, try and use the 'robocopy' command with the '/MT' (MultiThreading) option - Robocopy command description[^]
Quote:
The most important switch to focus on in the above command is /MT, which is the switch that enables Robocopy to copy files in multi-threaded mode. If you do not set a number next to the /MT switch, the default number will be 8, which means that Robocopy will try to copy eight files simultaneously.

Your command will be -
robocopy "source_path" "destination_path" /E /MOVE /MT:8


You can also use 'PowerShell' commands with the 'Get-ChildItem', 'Rename-Item' cmdlets to traverse the folder structure and rename the files/folders as it has better support for Unicode characters and long paths compared to VBScript - MS Learn | Get-ChildItem[^]
Get-ChildItem -Path "C:\very\long\path\to\your\problematic\folder" -Recurse | ForEach-Object {
    $newName = $_.Name -replace 'old_pattern', 'new_pattern'
    $_ | Rename-Item -NewName $newName
}


I hope some of these work for you.
 
Share this answer
 
Thanks for your suggestions, doing a more deep search I've found another sowftare (Bulk Rename Utility - Free File Renaming Software[^] ), which uses regex to specify find/replace of strings, so I can remove all Unicode chars, those NOT X'00'-x'7f' (ASCII) and this solves first half of the problem, then FileSystemObject will manage very long path and correct those with problems.
Thanks a lot
Luigi
 
Share this answer
 
Comments
PIEBALDconsult 6-Aug-23 20:24pm    
Please don't try to answer your own question; use the Improve question button to add detail.
lvTH 7-Aug-23 4:24am    
Sorry, but I didn't see such button on the page... I just want to close the problem giving thanks.
Luigi

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900