Forum Discussion
JCombs
Apr 22, 2021Copper Contributor
Scripting Help - Set File Date based on Folder Name (or How to Get Help)
Hi Community - I need help and hoping this is the place for it. Or if you can recommend where I should ask for this help, I would appreciate it. Obstacle: I have many files that I need the date...
SteveMacNZ
Apr 27, 2021Iron Contributor
you can you the below 1 liner to grab the folder name and load into a variable
$test = "C:\Temp\2005-12-15\FH0000013.jpg"
$test.split("\")[-1] will return FH0000013.jpg
$test.split("\")[-2] will return 2005-12-15 being the dated folder you are wanting
store it into variable you can then reuse in the rename
$fdate = $test.split("\")[-2]
$test = "C:\Temp\2005-12-15\FH0000013.jpg"
$test.split("\")[-1] will return FH0000013.jpg
$test.split("\")[-2] will return 2005-12-15 being the dated folder you are wanting
store it into variable you can then reuse in the rename
$fdate = $test.split("\")[-2]