On my Android phone, it was configured to save pictures to the Phone-memory.
I wanted to free up some memory in the phone, and since I have a 16GB uSD card, I:
1) copied all the pictures to my computer using the USB cable.
2) erased the picture files (and thumbnails) from the phone memory.
3) configured the phone to save pictures to the uSD card.
4) copied all the pictures from the computer to the uSD card on the phone.
All is working now, except that the timestamp (and sort-order) for all the pictures on the phone (uSD) are now all screwed up ... showing the date/time that I performed the copy operation.
Fortunately, the timestamps for the pictures on the computer are all correct.
I was thinking to write a script using PowerShell (or a combination of Batch/PowerShell) to:
1) for each picture file that exists in both the phone and computer...
2) read the timestamps (creation and modification) from the file on the computer
3) set the timestamps for the file on the phone memory card
The paths are something like:
Phone: "K:\DCIM\100Media"
Computer: "F:\Android\SDCard\DCIM\100Media"
What I have found so far about PowerShell, I could do:
$timestampw = (Get-ChildItem 'F:\Android\SDCard\DCIM\100Media\file1.jpg').LastWriteTime
$timestampc = (Get-ChildItem 'F:\Android\SDCard\DCIM\100Media\file1.jpg').CreationTime
(Get-ChildItem 'K:\DCIM\100Media\file1.jpg').LastWriteTime = $timestampw
(Get-ChildItem 'K:\DCIM\100Media\file1.jpg').CreationTime = $timestampc
I still need info about:
1) unclear determining when I should use "Get-ChildItem" vs. "Get-Item"
2) check if the file exists on the phone.
3) how to pass the paths / filenames to the PowerShell script.
4) how to refer to the command line arguments within the PowerShell script.
I could also use this in PowerShell to loop through all the files on the computer:
$files = Get-ChildItem 'F:\Android\SDCard\DCIM\100Media'
ForEach ($file in $files) ...
5) how to wrap all this up and create a PowerShell script file
As an alternative to doing this entirely in PowerShell, I could write a batch file to call PowerShell (command-line) twice for each file:
@echo off
set "sp=F:\Android\SDCard\DCIM\100Media"
set "dp=K:\DCIM\100Media"
cd "%sp%"
cd "%dp%"
F:
for %%f in ("*.jpg") do call :work "%%f"
goto :EOF
:work
set fn=%~1
set "ss=%sp%\%fn%"
set "ds=%dp%\%fn%"
if not exist "%ds%" goto :EOF
call PowerShell ... 'copy LastWriteTime from "%ss%" to "%ds%"
call PowerShell ... 'copy CreationTime from "%ss%" to "%ds%"
goto :EOF
For that to work, I just need to know how to compose the command-lines to call PowerShell.
Obviously the Batch/PowerShell method would be easier to complete, but for further understanding of PowerShell, it would be great to see both.
Also, is it possible to read the creation timestamp from the picture file meta-data using PowerShell ?
Thanks to all who can provide some help.