#1 22 Jan 2019 21:06

Commander_Keen
Member
Registered: 22 Jan 2019
Posts: 3

REN and MOVE for very long directory and file names exceeding MAX_PATH

Hi,

I'm trying to batch rename and/or move files which are stored a directory with long path so that path+filename exeed MAX_PATH.

While DEL is documented as being capable of using a syntax like this
DEL "\\?\C:\some long folder\long file name.txt" (ss64.com/nt/del.html)
commands like REN or MOVE are not.
As a lucky shot I tried anyway REN with "\\?\absolute path" and "\\?\.\long filename" but it complained that filename or extension is too long.

1) Where can see which commands support the "\\?\" syntax?
2) How can I rename and/or move such files in a batch?

Thanks for your thoughts.

Offline

#2 22 Jan 2019 21:13

Commander_Keen
Member
Registered: 22 Jan 2019
Posts: 3

Re: REN and MOVE for very long directory and file names exceeding MAX_PATH

Commander_Keen wrote:

While DEL is documented as being capable of using a syntax like this
DEL "\\?\C:\some long folder\long file name.txt" [...]

Okay, it seems I'm missing something, DEL also complains about too long path even when using "\\?\C:\long path\to\file.ext".

OS: Win2008 R2

Offline

#3 23 Jan 2019 22:47

RG
Member
From: Minnesota
Registered: 18 Feb 2010
Posts: 346

Re: REN and MOVE for very long directory and file names exceeding MAX_PATH

Take a look here
http://stackoverflow.com/questions/9787 … 8069#98069

I have done it like this.

SET "Folder=Your Folder\Structure"
RMDIR /S /Q "%Folder%" 2>nul & REM Delete what we can
MD "%Folder%\Empty"
ROBOCOPY.EXE "%Folder%\Empty" "%Folder%" /MIR >nul & REM Copy the Empty folder with /MIR to wipe out existing stuff
ECHO( >"%Folder%\%~nx0 Deleted Contents Of This Folder" & REM Put indication in folder that we deleted stuff

Windows Shell Scripting and InstallShield

Offline

#4 27 Jan 2019 18:45

Commander_Keen
Member
Registered: 22 Jan 2019
Posts: 3

Re: REN and MOVE for very long directory and file names exceeding MAX_PATH

Hum, thanks, but first of all I'd like to rename this file and move it before considering deletion of the whole folder. ;-)
I also would like to achieve that without external programs.

Offline

Board footer

Powered by FluxBB