[Solved] back up and restore the modified date

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
xnmp
Posts: 88
Joined: 15 Mar 2013 04:46

[Solved] back up and restore the modified date

Post by xnmp »

Hi, i want to back up and restore the modified date, created date of files (based on the filepath )
(I'm going to edit some files, and restore their date after editing )
for example i run "backup" and the script store the data into a text file like this

Code: Select all

 file | date modified | date created
e:\test1\a.jpg  | 5/3/2016 4:29:29 PM  | 5/3/2016 4:32:52 PM
e:\test2\b.jpg  | 5/3/2016 11:25:52 AM | 5/3/2016 11:25:52 AM
(or any other forms )
Then i run "restore" the script would read the text file and restore the modified date, created date of listed files
Any help would be much appreciated
Thank you
Last edited by xnmp on 05 May 2016 10:58, edited 2 times in total.

RalphM
Posts: 2121
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: back up and restore the modified date

Post by RalphM »

If you're using backupto for the backup as well as for the restore with preserve dates you shouldn't need to change the dates after the restore.
Ralph :)
(OS: W11 25H2 Home x64 - XY: Current x64 beta - Office 2024 64-bit - Display: 1920x1080 @ 125%)

xnmp
Posts: 88
Joined: 15 Mar 2013 04:46

Re: back up and restore the modified date

Post by xnmp »

RalphM wrote:If you're using backupto for the backup as well as for the restore with preserve dates you shouldn't need to change the dates after the restore.
Thank you very much ,actually i know it
I'm going to edit some files, and restore their date after editing

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: back up and restore the modified date

Post by highend »

Code: Select all

"_Initialize"
    global $logFile = "<curpath>\dates.txt";

"Backup file dates..."
    global $logFile;
    $logContent = "";
    foreach($file, <get SelectedItemsPathNames |>) {
        if (exists($file) != 1) { continue; }
        $created  = property("#date.c", $file);
        $modified = property("#date.m", $file);
        $logContent = $logContent . "$file|$created|$modified<crlf>";
    }
    writefile($logFile, $logContent);

"Restore file dates..."
    global $logFile;
    $logContent = readfile($logFile);
    foreach($line, $logContent, <crlf>) {
        $file     = gettoken($line, 1, "|");
        $created  = gettoken($line, 2, "|");
        $modified = gettoken($line, 3, "|");
        if (exists($file) != 1) { continue; }
        timestamp "c", $created, $file;
        timestamp "m", $modified, $file;
    }
One of my scripts helped you out? Please donate via Paypal

xnmp
Posts: 88
Joined: 15 Mar 2013 04:46

Re: back up and restore the modified date

Post by xnmp »

Omg you are so quick
I'll try it ,thank you very much ,highend

xnmp
Posts: 88
Joined: 15 Mar 2013 04:46

Re: back up and restore the modified date

Post by xnmp »

Hi highend,
Thank you very much for the help, ireally appreciate your effort
i 've just tried it , the modified and created date in list is differrent from the date propertiers in xyplorer
here is the result in text file

Code: Select all

E:\Temp\X3HA_01_01_01.unity3d|5/5/2016 3:11:40 PM|5/11/2015 8:35:13 AM
E:\Temp\X3HA_01_01_02.unity3d|5/5/2016 3:11:40 PM|5/11/2015 8:35:13 AM
E:\Temp\X3HH_01_01_00.unity3d|5/5/2016 3:11:40 PM|5/11/2015 8:35:13 AM
E:\Temp\X3HH_01_01_01.unity3d|5/5/2016 3:11:40 PM|5/11/2015 8:35:13 AM
E:\Temp\Yaz.unity3d|5/5/2016 3:11:40 PM|5/11/2015 8:35:13 AM
And here is what i copied from xyplorer propertiers (created/modified like in your script),the order is the same with the list file

Code: Select all

  (E:\Temp\X3HA_01_01_01.unity3d) 5/5/2016 3:11:40 PM | 5/11/2015 8:35:13 AM
  (E:\Temp\X3HA_01_01_02.unity3d) 5/5/2016 3:11:40 PM | 5/11/2015 8:35:04 AM
 (E:\Temp\X3HH_01_01_00.unity3) 4/29/2016 3:22:05 PM | 5/11/2015 8:34:36 AM
(E:\Temp\X3HH_01_01_01.unity3d) 5/5/2016 3:11:40 PM | 5/11/2015 8:35:07 AM  
 (E:\Temp\Yaz.unity3d) 5/5/2016 3:14:41 PM | 3/26/2015 10:51:56 PM
i have no idea why it 's so different, especially in the last line
Again,thank you very much :)

highend
Posts: 14996
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: back up and restore the modified date

Post by highend »

I see.

Use this instead:

Code: Select all

"_Initialize"
    global $logFile = "<curpath>\dates.txt";

"Backup file dates..."
    global $logFile;
    $logContent = "";
    foreach($file, <get SelectedItemsPathNames |>) {
        if (exists($file) != 1) { continue; }
        $created  = property("#date.c", $file);
        $modified = property("#date.m", $file);
        $logContent = $logContent . "$file|$created|$modified<crlf>";
    }
    writefile($logFile, $logContent);

"Restore file dates..."
    global $logFile;
    $logContent = readfile($logFile);
    foreach($line, $logContent, <crlf>) {
        $file     = gettoken($line, 1, "|");
        $created  = gettoken($line, 2, "|");
        $modified = gettoken($line, 3, "|");
        if (exists($file) != 1) { continue; }
        timestamp "c", $created, $file;
        timestamp "m", $modified, $file;
    }
One of my scripts helped you out? Please donate via Paypal

xnmp
Posts: 88
Joined: 15 Mar 2013 04:46

Re: back up and restore the modified date

Post by xnmp »

highend wrote:I see.

Use this instead:
Thank you ,i 've just tested, it works flawlessly
Thank you very much ,highend
you are so Great.

Post Reply