What up /g/, I need help in doing a script on windows. The script has to organize photos by year, month, day, hour, minute, second and milisecond. Something like this:
C:/Photos/AAAA/MM/DD/AAAA.MM:DD-HH.MM.SSss
AAAA as year
MM as month
DD as day
HH as hour
MM as minute
SS as second
ss as milisecond
If you can do it you save my ass.
install gentoo
>>54510411
It has to be done on WIndows, with cmd
>>54510385
Are the photos all in the same folder?
>>54510450
Yes
>>54510385
Can't Windows do that already?
>>54510705
Obviously. But It's and exercice I have to do.
>>54510385
sort based on meta data?
> milliseconds
> only two digits
wouldn't you need a million (9,999,999) to properly display MILiseconds?
>>54510733
Upload the dummy file your teacher is making you use and I'll give you the code.
>>54510784
You know the best part about this is that he gave me nothing to do it. Just "Do it. Search it for your own".
>>54510805
Alright give me like 30 mins I got you.
>>54510805
Go full pajeet and copy paste code from Stack Overflow
If you still got no idea what to look for to accomplish this task just drop out of whatever the fuck you're studying
>>54510385
there's the whole %D %Y %M shit on windows too, isn't there?
>>54510782
You're kidding right?
>>54510385
>The script has to organize photos by year, month, day, hour, minute, second and milisecond.
where are these coming from?
>>54510385
>>54510822
Here you go I didnt test it but beggars cant be choosers.
Basically a for statement just make sure you play with the time settings if something is off.
@echo off
md C:\Desktop\sorted
forfiles -p "C:\what\ever" -s -m *.* -d <0> -c "cmd move @path C:\Desktop\sorted"
pause
>>54511180
Also forgot to add the md makes a files to move your sorted items there.
I did the for method for files just update it to anything you need and play with the sorting.
>>54510758
So i'm a guy from OP's class, yes, it has to be sorted by metadata, the thing is, that the script needs to sort the pictures you drag into the script, and rename them. Then, move them to the right folder for year, month and day.
>>54511170
Yeah, my bad, sorry.
http://www.robvanderwoude.com/battech_fileproperties.php
http://ss64.com/nt/move.html
Do your homework.
If you cant do it with these two then you're retarded.
>>54510385
Colons are not permitted in Windows file names.
PowerShell:$items = (Get-ChildItem -Force)
ForEach ($item in $items) {
$millisecond = $item.LastWriteTime.Millisecond
$date = $item.LastWriteTime.DateTime | Get-Date -Format yyyy.MM.dd-HH.mm.ss
Rename-Item $item -NewName ($date + $millisecond + $item.Extension) -Force
}
Just don't run this from C:\Windows\system32, thank you. Wrap it in a function and put a mandatory path parameter if you want it reusable without running from a prompt/ISE.
>>54513604
Output of that scriptblock:PS > Get-ChildItem -Recurse -Include "*.png","*.jpg" | Select-Object -Property Name
Name
----
2013.02.21-18.37.17820.png
2013.02.21-18.37.18625.png
2013.06.09-03.44.34536.png
2013.12.07-22.42.40103.png
2014.06.21-03.57.14173.png
2014.06.29-05.12.00395.png
2014.07.10-14.05.140.jpg
2014.11.05-22.05.22198.jpg
2015.01.16-10.46.180.png
2015.05.30-15.14.39495.png
2015.07.19-01.59.17701.jpg
2015.07.19-01.59.20742.jpg
2015.08.13-23.08.17545.png
2015.12.26-02.57.16685.jpg
2015.12.27-03.04.50320.jpg
2016.01.29-16.08.30733.jpg
2016.03.25-04.49.12838.png
2016.03.25-05.10.34490.png
2016.03.25-05.14.00852.png
2016.03.26-18.30.18310.png
2016.03.26-18.32.12904.png
As you can see, it's in the desired format. You could make it much safer, as it will simply rename everything, but I gave you what you wanted. Just don't be a moron.
>>54513670
Yeah, it looks perfect, but the problem is that I can't use PowerShell. Only cmd, the only step I made is the command to move files to another folder.
>>54513717
in cmd:
>powershell.exe -executionpolicy unrestricted -file c:\path\to\the\script.ps1
fucking solved
you ain't making me use cmd like it's 1999.
why "can't" you use powershell anyway?
>>54510805
That's how it works in the real world you non contributing zero.
>>54513733
>>54513717
nvm, just read that it's your fucking homework
well, thanks for keeping my brain alive this thursday evening.
>>54513749
I've been searching for about 15 hours how to make that shit