1. 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

Discussion in 'T&T - Scripting' started by Schuby, Jan 1, 2010.

  1. Schuby

    Schuby

    Messages:
    5
    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
  2. Joe Caverly

    Joe Caverly

    Messages:
    419
    Hi,
    Not sure if this will work, but try replacing the P space with an asterisk. That is, replace P " with *"

    Joe
  3. dcantor

    dcantor

    Messages:
    351
    And if that doesn't work, try replacing the "P " with "P?" and then try
    "P[ ]".
  4. Schuby

    Schuby

    Messages:
    5
    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. Schuby

    Schuby

    Messages:
    5
    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. Steve Fabian

    Steve Fabian

    Messages:
    3,418
    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. Joe Caverly

    Joe Caverly

    Messages:
    419
    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
  8. Joe Caverly

    Joe Caverly

    Messages:
    419
    Followup:
    Apparently, the \\?\ convention is for Unicode, which allows file and folder names to be up to 32,000 wide characters.
    It works with a four character wide filename. This is all new to me. Maybe someone else can explain this convention.

    Joe
  9. Charles Dye

    Charles Dye Super Moderator Staff Member

    Messages:
    2,426
    It's UNC applied to local filenames. The "computer name" is a question mark, and the "share name" is the drive letter (without a colon.) So e.g. \\?\D\FOO\BAR would refer to the file D:\FOO\BAR on the local computer.
  10. Schuby

    Schuby

    Messages:
    5
    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

Share This Page