• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Rename issue, space at end of name

#1
Previously, you've helped me with renaming files using wildcards - thanks so much - got that working with a script after checking the forum.

Now I'm stuck with a folder name that I cannot change, even using the window's rename command. Below is the folder name that's giving me trouble during backup copies, as the OS cannot locate the folder:

"C:\DSP\NoBS\InfernoSeniorsDSP\inferno seniors-1 DSP "

I believe the problem is that there is a space char at the end of the folder name. I've tried the below by using its the short filename:
[C:\DSP\NoBS\InfernoSeniorsDSP]ren INFERN~1 X
TCC: (Sys) The system cannot find the file specified.
"C:\DSP\NoBS\InfernoSeniorsDSP\INFERN~1"
0 files renamed

This one has me stumped. How can I rename this to get rid of the space at end of the name?

Thanks in advance!
-George
 
#4
Hi,
Not sure if this will work, but try replacing the P space with an asterisk. That is, replace P " with *"

Joe
Hi Joe-

Didn't work yet; seems to strip off the space at the end:

[C:\DSP\NoBS\InfernoSeniorsDSP]ren "inferno seniors-1 DSP*" x
C:\DSP\NoBS\InfernoSeniorsDSP\inferno seniors-1 DSP -> C:\DSP\NoBS\InfernoSeniorsDSP\x
TCC: (Sys) The system cannot find the file specified.
"C:\DSP\NoBS\InfernoSeniorsDSP\inferno seniors-1 DSP"
0 files renamed

Besides the short name, is there another way to edit the folder name?

-George
 
#5
And if that doesn't work, try replacing the "P " with "P?" and then try
"P[ ]".
Hi Joe-

Below are the results, interesting that the rd "error msg" recognizes the space at the end; but still none of these work yet. I tried both rd and ren commands - with slightly different error messages:

[C:\DSP\NoBS\InfernoSeniorsDSP]rd "inferno seniors-1 DSP?"
TCC: (Sys) The system cannot find the file specified.
"C:\DSP\NoBS\InfernoSeniorsDSP\inferno seniors-1 DSP "

[C:\DSP\NoBS\InfernoSeniorsDSP]rd "inferno seniors-1 DSP[ ]"
TCC: (Sys) The system cannot find the file specified.
"C:\DSP\NoBS\InfernoSeniorsDSP\inferno seniors-1 DSP "

["C:\DSP\NoBS\InfernoSeniorsDSP]ren "inferno seniors-1 DSP?" x
"C:\DSP\NoBS\InfernoSeniorsDSP\inferno seniors-1 DSP -> "C:\DSP\NoBS\InfernoSeniorsDSP\x
TCC: (Sys) The system cannot find the file specified.
"C:\DSP\NoBS\InfernoSeniorsDSP\inferno seniors-1 DSP"
0 files renamed

["C:\DSP\NoBS\InfernoSeniorsDSP]ren "inferno seniors-1 DSP[ ]" x
"C:\DSP\NoBS\InfernoSeniorsDSP\inferno seniors-1 DSP -> "C:\DSP\NoBS\InfernoSeniorsDSP\x
TCC: (Sys) The system cannot find the file specified.
"C:\DSP\NoBS\InfernoSeniorsDSP\inferno seniors-1 DSP"
0 files renamed

Didn't work; but thank you for your suggestions!
-George
 
#6
Schuby wrote:
| Didn't work; but thank you for your suggestions!

Another suggestion: try using filename completion! Of course, you can only
do that interactively, not in a batch program file.
--
HTH, Steve
 
#7
Hi Joe-

Besides the short name, is there another way to edit the folder name?

-George
Hi;
From http://support.microsoft.com/kb/320081;

Cause 6: The file name includes an invalid name in the Win32 name space

<script type="text/javascript"> loadTOCNode(2, 'moreinformation'); </script> You may not be able to delete a file if the file name includes an invalid name (for example, the file name has a trailing space or a trailing period or the file name is made up of a space only). To resolve this issue, use a tool that uses the appropriate internal syntax to delete the file. You can use the "\\?\" syntax with some tools to operate on these files, for example: del "\\?\c:\<var>path_to_file_that contains a trailing space.txt</var> "
The cause of this issue is similar to Cause 4. However, if you use typical Win32 syntax to open a file that has trailing spaces or trailing periods in its name, the trailing spaces or periods are stripped before the actual file is opened. Therefore, if you have two files in the same folder named "AFile.txt" and "AFile.txt " (note the space after the file name), if you try to open the second file by using standard Win32 calls, you open the first file instead. Similarly, if you have a file whose name is just " " (a space character) and you try to open it by using standard Win32 calls, you open the file's parent folder instead. In this situation, if you try to change security settings on these files, you either may not be able to do this or you may unexpectedly change the settings on different files. If this behavior occurs, you may think that you have permission to a file that actually has a restrictive ACL.
I've never heard of the \\?\c:\<var>path_to_file_that contains a trailing space.txt</var> " convention before. Not sure what the \\?\ means. While the KB article talks of using DEL, maybe it will work with other commands?

Joe
 
#8
Hi;
From http://support.microsoft.com/kb/320081;

I've never heard of the \\?\c:\<var>path_to_file_that contains a trailing space.txt</var> " convention before. Not sure what the \\?\ means. While the KB article talks of using DEL, maybe it will work with other commands?

Joe
Followup:
Apparently, the \\?\ convention is for Unicode, which allows file and folder names to be up to 32,000 wide characters.
TCC:1136: 26 > cd \utils

TCC:1136: 27 > md \\?\c:\utils\Test

TCC:1136: 28 > dir Test

Volume in drive C is unlabeled Serial number is 0c63:67ff
Directory of C:\utils\Test\*

1/02/2010 15:57 DIR .
1/02/2010 15:57 DIR ..
0 bytes in 0 files and 2 dirs
204,692,656,128 bytes free

TCC:1136: 29 > rd \\?\c:\utils\Test
It works with a four character wide filename. This is all new to me. Maybe someone else can explain this convention.

Joe
 
#10
Hi;
From http://support.microsoft.com/kb/320081;

I've never heard of the "\\?\c:\<var>path_to_file_that contains a trailing space.txt</var> " convention before. Not sure what the \\?\ means. While the KB article talks of using DEL, maybe it will work with other commands?

Joe
Joe - you rock!

It didn't quite work as shown in the tech note; but I did finally get it done:

Did NOT work (seemed to ignore the last space at the end) :
rd "\\?\c:\<var>path_to_folder_that contains a trailing space.txt</var> "

Did NOT work
(wants full path apparently) :
rd "\\?\.\<var>path_to_folder_that contains a trailing space.txt</var> "

Did work:
rd "\\?\c:\<var>path_to_</var>folder<var>_that contains a trailing space.txt</var>[ ]"

Thanks everyone! Learned something new today.
-George
 
Top Bottom