How to? File rename problem...

May 24, 2010
855
0
Northlake, Il
This is not strictly a TCmd/TCC problem, but since I did it with TCC, I'm hoping there's some way to undo it with TCC. You see, due to a malformed "ren" command (in a loop as I remember), I ended up with a whole bunch (21) of files with names like (this is accurate in terms of the length of the file name) "ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrors That Were Stupid Renaming Files Using Wildcards.txt". These names can not be handled by TCC (can not copy, move, rename or delete them) because the names are too long. So the question is - is there any known way to rename them (I'd prefer to keep them). Windows Explorer (tried in desperation) is also unable to handle them.
 
May 20, 2008
3,515
4
Elkridge, MD, USA
I would try using a wildcard for the source name (preferrably one that is unique for a single one of those 21 files), and a short target name, for the REN or MOVE command. I'd try this with CMD.EXE if TCC cannot do it... Also, part of the problem may be that the path + filename is too long; I'd rename the directory holding the files to something like "X:\1" (i.e., into the root, with a single character name).
Good luck!

Oh, maybe an archiving command / program, or a full version of V could handle it...
 
May 20, 2008
11,437
99
Syracuse, NY, USA
I don't recall the details, but there's a construction beginning with, I believe, "\\?\" that can help with long file names.

That said, your file name seems about 100 characters shy of the usual MAX_PATH = 260 limit.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,469
88
Albuquerque, NM
prospero.unm.edu
Use CMD.EXE. Change to the directory containing the offending files and use DIR /X to find their short names. Rename them using the short names.

Unfortunately, you can't do this in TCC. When you pass TCC a short filename, it automagically substitutes the long name before passing it on to Windows....
 
May 24, 2010
855
0
Northlake, Il
Steve, your solution worked. And I will note that the files were in the root directory of my Z:\ drive (a RAM disk) and so therefore the length of the full path could not be part of the problem. But thank you!

Vince, I can't explain what you say about my file names being shorter than the supposed limit, I just know that 1. The erroneous rename process stopped for any one file when it hit the limit whatever it was, and 2. I could not rename the files using "standard" techniques. And for whatever reason(s) "\\?\" did not work (and I tried it, using some variations, dozens of times). I probably spent two or three hours on it before making the posting.

And Charles, I didn't think to try cmd.exe, I just found out I couldn't do that in TCC. But, thankfully, problem solved, and satisfactorily to boot.

Thank you to all of you!
 
May 20, 2008
11,437
99
Syracuse, NY, USA
Vince, I can't explain what you say about my file names being shorter than the supposed limit, I just know that 1. The erroneous rename process stopped for any one file when it hit the limit whatever it was, and 2. I could not rename the files using "standard" techniques. And for whatever reason(s) "\\?\" did not work (and I tried it, using some variations, dozens of times). I probably spent two or three hours on it before making the posting.

The file name you posted poses no problem to a normal NTFS drive (see below). What kind of file system is on your ramdrive?
Code:
v:\> touch /c ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErr
ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrEr
rErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrors
2012-12-13 19:36:20.444  V:\ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrE
rrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErr
ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrors
 
v:\> dir err*
 
Volume in drive V is DATA          Serial number is c007:d3e4
Directory of  V:\err*
 
2012-12-13  19:36              0  ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErr
ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrEr
rErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrors
2012-08-09  20:42            109  error.btm
              109 bytes in 2 files and 0 dirs    4,096 bytes allocated
    6,677,204,992 bytes free
 
v:\> del ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrEr
rErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrE
rrErrErrErrErrErrErrErrErrErrErrErrErrErrErrors
Deleting V:\ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrEr
rErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrE
rrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrors
    1 file deleted
 
May 24, 2010
855
0
Northlake, Il
Vince, chkdsk reports it as being NTFS (which I was 99% sure was the case), although it is a RAM disk and not a physical hard disk (I somehhow doubted if that made a difference, and I was right - see below). As far as your tests succeeding, I have two notes to make: #1, There were two sequential blanks in the name I submitted (which maybe didn't survive the bulletin board if you copied the name from there), and #2, That was (obviously) not the "real" file name, it was a "transcription" of same (which was somewhat personal as my file names tend to be fully descriptive). However, I just created a file with that name (with the double blanks) on my RAM disk, and I was not able to delete it until I renamed it using the wildcard technique suggested in this thread. I also just created it on a "real", physical, hard disk, and I was not able to delete it there either without using the same technique.
 
May 20, 2008
11,437
99
Syracuse, NY, USA
I have no trouble with the "Err..." name, even with spaces/double spaces. Is it possible your actual filename contained troublesome characters?
 
May 24, 2010
855
0
Northlake, Il
Vince, I have no explanation for this either other than to say that I recreated a file with that name on both the RAM disk and on a physical hard disk before making the posting and, again, I was not able to copy, move, rename, or delete either of them using "standard" techniques. (I saved the problem file name into a file so there would could be no mistake(s).) I am showing the file name here with the spaces replaced by underscores so there can be no mistakes/misunderstandings.

ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrors__That_Were_Stupid_Renaming_Files_Using_Wildcards.txt
 
May 20, 2008
11,437
99
Syracuse, NY, USA
Vince, I have no explanation for this either other than to say that I recreated a file with that name on both the RAM disk and on a physical hard disk before making the posting and, again, I was not able to copy, move, rename, or delete either of them using "standard" techniques. (I saved the problem file name into a file so there would could be no mistake(s).) I am showing the file name here with the spaces replaced by blanks so there can be no mistakes/misunderstandings.

ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrors__That_Were_Stupid_Renaming_Files_Using_Wildcards.txt
That one gives me no trouble. ... anyone else? At 240+ characters, it's close to MAX_PATH = 260. Note that the DEL command shows that TCC used the "\\?\" path spec even though I didn't.
Code:
v:\> touch /c "ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrEr
rErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrE
rrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrors  That Were Stupid Renaming
Files Using Wildcards.txt"
2012-12-13 22:10:35.472  V:\ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErr
ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrors  That Were Stupid Renaming Files Using Wildcards.txt
 
v:\> del "ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErr
ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrors  That Were Stupid Renaming Files Using Wildcards.txt"
Deleting \\?\V:\ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErr
ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrors  That Were Stupid Renaming Files Using Wildcards.txt
    1 file deleted
 
May 24, 2010
855
0
Northlake, Il
Vince, I had no explanation for this, either; I just know that I am not 99.999% sure that things were as I represented them, I am 100% sure. (And I will note that the name is 251 characters long and there's no chance I made a mistake when acquiring that number.)

But I just did it yet another time using the name with the spaces with exactly the same results, no surprise. However I had no problems with the file when the spaces were replaced by underscores, and that was a surprise (for me). And I just found the answer to the question: a file delete with a leading "\\?\" (placed there manually by me) fails for a file name with underscores and succeeds if I don't manually add the leading "\\?", and I have no idea why that should be the case. And there is no way to remove the added "\\?" when the file name has spaces because the leading "\\?\" is placed there by TCC. cmd.exe (which doesn't do that) has no problem deleting either file.) Here is an unmodified transcript of a TCC session for reference.
Code:
  Thu  Dec 13, 2012  9:56:49p
 
Chill v1.1.0 loaded.
TCC: Plugin already loaded "Event64"
HTags plugin v0.60.3 loaded.
HTMLDump plugin v1.0.5 loaded.
ISO8601 plugin v1.3.7 loaded.
PopInfo v1.0.3 loaded; hotkey is Control-Q.
QCAL plugin v1.3.7 loaded.
SafeChars plugin v1.7.0 loaded.
Say plugin v1.0.7 loaded.
 
TCC  14.03.52 x64  Windows 7 [Version 6.1.7601]
Copyright 2012 JP Software Inc.  All Rights Reserved
Registered to Daniel Mathews
 
[Z:\]Type NUL: >ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrE
rrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErr
ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrors__That_Were_Stupid_Renaming_Files_U
sing_Wildcards.txt
 
[Z:\]del \\?\ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrE
rrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErr
ErrErrErrErrErrErrErrErrErrErrErrErrErrErrors__That_Were_Stupid_Renaming_Files_Usin
g_Wildcards.txt
TCC: (Sys) The filename, directory name, or volume label syntax is incorrect.
"\?\Z"
    0 files deleted
 
[Z:\]del ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrEr
rErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrE
rrErrErrErrErrErrErrErrErrErrErrErrErrors__That_Were_Stupid_Renaming_Files_Using_Wi
ldcards.txt
Deleting \\?\Z:\ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrE
rrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErr
ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrors__That_Were_Stupid_Renaming_Files_U
sing_Wildcards.txt
    1 file deleted
 
[Z:\]type Nul: >"ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErr
ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrEr
rErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrors  That Were Stupid Renaming Files
Using Wildcards.txt"
 
[Z:\]dir err*
 
Volume in drive Z is RAM Disk      Serial number is 8ab4:1647
Directory of  Z:\err*
 
12/13/2012  21:53              0  ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErr
ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrEr
rErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrors  That Were Stup
id Renaming Files Using Wildcards.txt
                0 bytes in 1 file and 0 dirs
      106,151,936 bytes free
 
[Z:\]del "\\?\ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErr
ErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrErrEr
rErrErrErrErrErrErrErrErrErrErrErrErrErrErrors  That Were Stupid Renaming Files Usi
ng Wildcards.txt"
TCC: (Sys) The filename, directory name, or volume label syntax is incorrect.
"\?\Z"
    0 files deleted
 
[Z:\]
 
Similar threads
Thread starter Title Forum Replies Date
Joe Caverly Rename file that begins with Emoji Support 7
J History file load hangs if file has complete garbage in it... Support 1
jdanielp Cannot step into and/or call another .bat file when debugging .bat file Support 2
thorntonpg file explorer - short cut keys Support 1
JohnQSmith New online help file wrong logo Support 7
Jay Sage WAD Possible Bug With OPTION Command With @FILE Support 5
samintz How to? swap endianness in a binary file Support 12
vefatica `Back quotes` - command line vs. batch file Support 5
fpefpe How to? batch file size Support 2
Jay Sage Issues With TCMD File Explorer Support 0
FreezerBurnt Help making a CMD and TCC compatible batch file Support 7
Joe Caverly @FILESIZE and NTFS File Stream Support 1
Joe Caverly Embedding an .EXE (or other file) into a .BTM Support 8
U Command help on file names Support 5
S Concatenate all playlists into 1 file Support 22
Joe Caverly Set a batch variable (%1 - %n) when TCC is executing a batch file Support 5
Joe Caverly PSHELL and NTFS File Streams Support 2
P Kill all other instances of tcc from a btm batch file Support 2
D ffind hangs on large file Support 18
Alpengreis Documentation Minor issue in help file for view /E Support 1
fpefpe batch file ending early Support 18
J Licesne file location Support 1
K robocopy cancelling batch file processing Support 28
Jay Sage TCMD Crashes with "tctoolbar /c /r file" Support 5
A Unable to pass batch file arguments unaltered Support 18
MikeBaas How to...extract a string from a .json-file? Support 10
vefatica LIBRARY and file name completion? Support 4
D What does the file "..\Everything\Run history.csv" store? Support 5
H Takecommand.pdf failed not a pdf file Support 6
Joe Caverly DIRectory Colorization in v25 Help File Support 0
C show file description? with dir? Support 8
D When copying/moving, appending " (2)" to filename when the target file already exist. Support 7
R How to? Dir specific file search patterns with spaces in the pathnames? Support 6
Joe Caverly _EXPANSION in help file Support 0
Stefan Hassel Installation file TC 24.02 Build 47 is actually version 25.00.1 Support 10
vefatica Are @FILEDATE[file] and @FILEDATE[file,u] ever different? Support 2
K_Meinhard Help file error Support 1
Joe Caverly JOBMONITOR in Help File Support 1
D btm file command line augments comparing for string or math. Support 12
A Documentation [Help file] OPTION "//" synopsis formatting issue Support 0
vefatica Can TCC complete this file name? Support 5
G tcedit ist not run in tc 24 file explorer Support 10
M How to set Path variable for non-executable file extensions in 4DOS Support 8
I zip /M fails to delete file after adding to zip file Support 2
Charles Dye Is the "File Associations" installer dialog working? Support 4
J File explorer handling from command line? Support 2
Joe Caverly v24 Help File - DATEMONITOR Support 1
MickeyF Why does this batch file give me 'unknown command "else"' error? Support 17
vefatica TYPE goes crazy with no-BOM Unicode file Support 7
J built in file explorer - how do i go back "up" the directory? Support 2

Similar threads