1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

RoboCopy Query

Discussion in 'All Other Software' started by DDL, Nov 27, 2009.

Thread Status:
Not open for further replies.
  1. DDL

    DDL Thread Starter

    Joined:
    Nov 27, 2009
    Messages:
    1
    I am copying files with dates in the filename (filename_20091127.txt) from one location to another. How can I drop the date from the filename when moving/having moved the files accross? The file types and filenames vary from file to file but the date format will always be '_YYYYMMDD'. Is this something that can be done with RoboCopy and if so, how? If not, with what and how? Thanks in advance.
     
  2. TheOutcaste

    TheOutcaste

    Joined:
    Aug 7, 2007
    Messages:
    9,028
    Robocopy doesn't rename files.

    Welcome to TSG!

    For this, I'd use RenameMaster, and just remove the last 9 characters of the file name.

    It's on the Scripting tab, about 8th item down, Remove Beginning/Ending

    If this is a daily occurrence, you could write a batch file to remove the date after all the files are copied. Not too hard to just remove the last 9 characteers in a name.
    If you need to check for resulting duplicates or confirm it's actually an underscore followed by a date it would get more complex.

    Code:
    Setlocal EnableDelayedExpansion
    Set _Folder=C:\Location of Files
    PushD %_Folder%
    For /F "Tokens=* Delims=" %%I In ('Dir /B "%_Folder%\*.*"') Do (
    Set _Fname=%%~nI
    Rename "%%I" "!_Fname:~0,-9!%%~xI"
    )
    PopD
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/880798

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice