Sign in to follow this  
Followers 0
Diana (Cda)

Adding date before extension on copied files?

3 posts in this topic

I have this line in a script and it does a great job:

FileCopy("C:\Documents and Settings\Application Data\Microsoft\Outlook\*.*", "C:\Documents and Settings\Desktop\Outlook-\*.*")

I get this type of result below. Although the script copied about 7 files, I'm just showing 2 here:

outcmd.dat

MS Exchange Settings.RWZ

Is it possible, instead, to get the same but with a date and time stamp at the end before the extension on when the copy was made, like this (with the extension re-copied)?:

outcmd.dat - 2006.01.02.Tu., 17h28.dat

MS Exchange Settings.RWZ - 2006.01.02.Tu., 17h28.RWZ

I have another AI script, kindly provided by a poster here a year or so ago, and it gives me the date format I need, if that's any help -- although the code below goes to the clipboard and I need instead to get the code to put the info re date, as well as the time, in each filename as per the example just above:

;
; AutoIt v3.0
;

SoundPlay ("D:\AUTOIT\Scripts\WAVs\Robotz Menu Popup.wav")

#include <date.au3>
$thisday = StringMid("Sn,Mn,Tu,Wd,Th,Fr,Sa", StringInStr("SunMonTueWedThuFriSat", _DateDayOfWeek(@WDAY,1) ), 2)

ClipPut(@YEAR & '.'  & @MON & '.'  & @MDAY & '.' & $thisday)

Sleep(500)

Exit
; finished
TIA!

Thanks! :">

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Use _FileListToArray()

something like this my old piece of code for renaming, in your case with FileCopy:

#Include <File.au3>
#Include <Array.au3>

$FileList=_FileListToArray(".","*.zip",1)
If @Error = 0 And IsArray($FileList) Then 
    _ArraySort($FileList,0,1)
    
    For $j = 1 to UBound($FileList) - 1
        $name = $FileList[$j]
        $header = FileRead ($name,3) 
        If $header = "Rar" Then FileMove($name, StringReplace($name, ".zip",".rar"))
    Next
EndIf

Inside For Loop change name of file with your date logic...

Edited by Zedna

Share this post


Link to post
Share on other sites

This looks interesting. I can't make heads or tails of it, though. It looks like it might need 2 external au3 files (?). And rar and zip are mentioned. I'm not sure I have the knowledge to do the drastic editing to get this to work from my simple filecopy to what is needed to just add the date and time before the extension to the copied files. <sigh>

Well, I'll just have to keep looking for a solution.

Thanks for this, though. Not your fault that I couldn't figure out how to get it to work. Thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0