Script help

What up Sup Forums, 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.

Other urls found in this thread:

robvanderwoude.com/battech_fileproperties.php
ss64.com/nt/move.html
twitter.com/SFWRedditGifs

install gentoo

It has to be done on WIndows, with cmd

XD

Are the photos all in the same folder?

Yes

Can't Windows do that already?

Obviously. But It's and exercice I have to do.

sort based on meta data?

> milliseconds
> only two digits
wouldn't you need a million (9,999,999) to properly display MILiseconds?

Upload the dummy file your teacher is making you use and I'll give you the code.

No

You know the best part about this is that he gave me nothing to do it. Just "Do it. Search it for your own".

Alright give me like 30 mins I got you.

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

there's the whole %D %Y %M shit on windows too, isn't there?

You're kidding right?

>The script has to organize photos by year, month, day, hour, minute, second and milisecond.
where are these coming from?

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 -c "cmd move @path C:\Desktop\sorted"
pause

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.

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.

Yeah, my bad, sorry.

robvanderwoude.com/battech_fileproperties.php
ss64.com/nt/move.html
Do your homework.
If you cant do it with these two then you're retarded.

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.

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.

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.

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?

That's how it works in the real world you non contributing zero.

nvm, just read that it's your fucking homework

well, thanks for keeping my brain alive this thursday evening.

I've been searching for about 15 hours how to make that shit