+ Post New Thread
Results 1 to 4 of 4
Scripts Thread, Move a file to a folder then append the file name with the date in Coding and Web Development; I have a folder : G:\stf_info\techs\UNITeDownloads It contains 2 files : Login.csv Gmail.csv Every day (Monday - Friday) I would ...
  1. #1

    Join Date
    Jan 2007
    Posts
    964
    Thank Post
    10
    Thanked 35 Times in 27 Posts
    Rep Power
    22

    Move a file to a folder then append the file name with the date

    I have a folder :

    G:\stf_info\techs\UNITeDownloads

    It contains 2 files :

    Login.csv
    Gmail.csv

    Every day (Monday - Friday) I would like to rename the file to Login010101.csv (010101 being the date!) and move it across to the G:\stf_info\techs\UNITeDownloads\Archive sub folder

    Is there an easy way to do this?

  2. #2

    Domino's Avatar
    Join Date
    Oct 2006
    Location
    Bromley
    Posts
    4,126
    Thank Post
    215
    Thanked 1,255 Times in 786 Posts
    Blog Entries
    4
    Rep Power
    505
    Batch file as a scheduled task?

    @echo off
    set Source=G:\stf_info\techs\UNITeDownloads
    set Target=G:\stf_info\techs\UNITeDownloads\Archive
    FOR /f "tokens=1-5 delims=/.:- " %%A in ("%date%") DO (
    SET Month=%%A
    SET Day=%%B
    SET Year=%%C
    SET All=%%A%%B%%C
    )

    FOR %%i IN ("%Source%\*.csv") DO ^
    COPY "%%i" "%Target%\%%~Ni %All%.csv"

  3. Thanks to Domino from:

    googlemad (17th February 2014)

  4. #3
    ascott2's Avatar
    Join Date
    Nov 2007
    Posts
    181
    Thank Post
    18
    Thanked 37 Times in 29 Posts
    Rep Power
    20
    If you want it in powershell, this should do you

    Code:
    $source = "G:\stf_info\techs\UNITeDownloads\login.csv"
    $target = "G:\stf_info\techs\UNITeDownloads\Archive"
    Move-Item $source ("$target\login{0:ddMMyy}.csv" -f(get-date))
    and then just setup a scheduled task.

  5. Thanks to ascott2 from:

    googlemad (17th February 2014)

  6. #4

    Join Date
    Jan 2007
    Posts
    964
    Thank Post
    10
    Thanked 35 Times in 27 Posts
    Rep Power
    22
    Thanks for the help, the command prompt stuff did the trick for now (Still getting my head round Powershell!)

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 5
    Last Post: 29th January 2013, 10:16 AM
  2. Replies: 4
    Last Post: 11th February 2011, 04:36 PM
  3. Notification of added file to network folder
    By misterchris in forum Wireless Networks
    Replies: 6
    Last Post: 22nd September 2009, 02:41 PM
  4. Replies: 1
    Last Post: 21st January 2007, 02:51 PM
  5. Replies: 6
    Last Post: 20th October 2005, 06:48 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •