ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Coding Snacks

Update Timestamp of file based on time in filename

<< < (2/4) > >>

skwire:
see pm-dcwul62 (April 02, 2018, 07:59 AM)
--- End quote ---

Hmmm...never got a PM; you sure you sent it to me?

dcwul62:
Sorry ...

I just now noticed: I accidentally clicked on the envelope-button, which is 'sending an email'.
Did you receive an email?

skwire:
Sorry ...
I just now noticed: I accidentally clicked on the envelope-button, which is 'sending an email'.
Did you receive an email?-dcwul62 (April 02, 2018, 11:47 PM)
--- End quote ---

I did not.

4wd:
√ FilenameXYZ Bla-bla 12022011 130254.txt
√ FilenameXYZ Bla-bla 20141115_020218.txt
√ PatchToFiles-Video_2018-04-04_091419.wmv
√ Another F'n crappy name-2011_02_01-184901.sfa
√ Some-Other-Stupid-Filename .... 1999..12%&()23 ..!_- 231402.fck
√ Yet Another Example of Poor Standardised Naming-2001+08+03---15;34;34.dcm
√ Example of Poor Naming 32 - 03+03+2013---23;42;00.dcm


TfN.ps1


--- Code: PowerShell ---Param (  [string]$file,  [int32]$type = 2)# Types: 0 = Creation Time#        1 = Last Access Time#        2 = Modified Time#        3 = All of them $fileObject = Get-ChildItem -Path $file$wanted = (($fileObject.BaseName | %{ -join $_[$_.Length..0] }) -Replace '(\D)', '').Substring(0,14)  | %{ -join $_[$_.Length..0] }$pattern = 'yyyyMMddHHmmss'If ($wanted.Substring(4, 2) -gt "12") { $pattern = 'ddMMyyyyHHmmss' }$date = [DateTime]::ParseExact($wanted, $pattern, $null)Switch ($type) {  "0" {$fileObject.CreationTime = $date; break}  "1" {$fileObject.LastAccessTime = $date; break}  "2" {$fileObject.LastWriteTime = $date; break}  default {    $fileObject.CreationTime = $date    $fileObject.LastAccessTime = $date    $fileObject.LastWriteTime = $date  }}
TfN.ps1 <file> <type>

type = Read script

Example:
.\TfN.ps1 "ProgFileW10PShellModules.snippets-06-20141230 123720.txt" 0

Update Timestamp of file based on time in filename

Update Timestamp of file based on time in filename

TfN.cmd <dir> <type>

--- Code: Text ---pushd %1for /f "usebackq tokens=* delims=" %%a in (`dir "%~1" /b /a-d-h-r`) do (      powershell.exe -ExecutionPolicy Bypass -File C:\PoSh\TfN.ps1 "%%~a" %2      )popd
Update Timestamp of file based on time in filename

Update Timestamp of file based on time in filename

dcwul62:
Sorry ...
I just now noticed: I accidentally clicked on the envelope-button, which is 'sending an email'.
Did you receive an email?-dcwul62 (April 02, 2018, 11:47 PM)
--- End quote ---

I did not.

-skwire (April 02, 2018, 11:51 PM)
--- End quote ---

"Your message has been sent successfully."

please could you check again?

thanks a lot!

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version