Rename issue, space at end of name

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

  1. Schuby

    Message Count:
    4
    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

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

    Joe
  3. dcantor

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

    Message Count:
    4
    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

    Message Count:
    4
    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

    Message Count:
    2,718
    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

    Message Count:
    279
    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

    Message Count:
    279
    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 Super Moderator

    Message Count:
    2,140
    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

    Message Count:
    4
    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

Users found this page by searching for:

  1. rename folder with trailing space

    ,
  2. rename folder with space at end

    ,
  3. change folder name with asterisk on windows 7

    ,
  4. windows rename file with space at end,
  5. windows file with space at end,
  6. rename directory with space at the end,
  7. windows rename files with trailing spaces,
  8. windows rename file space at end#,
  9. rename command window,
  10. windows 7 rename folder end period,
  11. trailing space folder name,
  12. remove spaces when renaming windows files,
  13. windows 7 command to delete folder with space behind,
  14. rename folder with dot at end in windows 7,
  15. rename directory with space name in cmd,
  16. windows rename file ending with space