1

I have a Files they have a Date in the name.

ex:
2017-07-10 12-25-46[Work].wav
...

and i want to sort/move the Files in Folders like this

2017-07-10 12-25-46[Work].wav -> /2017.28/2017-07-10 12-25-46[Work].wav
...

i searched in the internet for this Problem but there is not much to find.

hopping you guys can help me

i just found this function on google:

function Get-WeekNumber([datetime]$DateTime = (Get-Date)) {
    $cultureInfo = [System.Globalization.CultureInfo]::CurrentCulture
    $cultureInfo.Calendar.GetWeekOfYear($DateTime,$cultureInfo.DateTimeFormat.CalendarWeekRule,$cultureInfo.DateTimeFormat.FirstDayOfWeek)
}

I am a programming noob. can just desribe the code with my words.

  1. Loading Filenames in to a varible.
  2. date(a) = split Filename(a) by " "
  3. extract year and week from date(a)[0]
  4. move file from current localtion to $targetlocation/$year.$week/$Filename(a)
  5. a++ and goto 2
mikki
  • 43
  • 3
  • Can you give some guide as to OS, please - ie windows/Unix/Linux, and possibly what batch language you wish to use? the use os the word "Folders" _suggests_ windows, but is sometimes used in the Unix world too. – Graham Nicholls Apr 01 '19 at 10:26
  • Depending on your locale, there are different definitions of a [calendar week](https://en.wikipedia.org/wiki/Week) [Ritchie Lawrence Batch Library](https://ritchielawrence.github.io/batchfunctionlibrary/#date-and-time-functions) has functions for ISO 8601 week. –  Apr 01 '19 at 10:28
  • [possible duplicate](https://stackoverflow.com/questions/39374549/iso-week-number-in-cmd) and [related](https://stackoverflow.com/questions/42826588/date-convert-to-week-number) – Stephan Apr 01 '19 at 10:35
  • I use Windows. And Batch language ? i think Batch is the language in .bat files. i am in germany. a week is here monday - sunday[mo - su] – mikki Apr 01 '19 at 10:42
  • 1
    It's important to note that batch files are seeing only on string, not a date object. In order to determine a week number based upon the content of the string you'd need to read each string, and perform a conversion through arithmetic operations. Take a look at `Set /?` from the Command Prompt, specifically that using the `/A` option. If you want to make the entire process less difficult, you should consider leveraging another scripting language, such as `WSH` or `PowerShell`, which have built-in methods for working with date objects. – Compo Apr 01 '19 at 10:46
  • i am fine with Powershell. batch is easy to use/edit for my solutions i think every script language has this ability. – mikki Apr 01 '19 at 11:01
  • @mikki As a German search for ISO8601 week definition. As the week number for Jan 1..3 could belong to the previous year / the week number for Dec 29..31 to the next year - a valid weeknumber has to contain also the year. Not all solutions do get that right. –  Apr 01 '19 at 13:27

0 Answers0