Timeline for Batch file move to directory structure based on filename
Current License: CC BY-SA 3.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 27, 2013 at 6:43 | history | edited | slm♦ | CC BY-SA 3.0 |
added 603 characters in body
|
| Oct 27, 2013 at 6:38 | comment | added | slm♦ | @Serge - yes so that's why the options aren't working. | |
| Oct 27, 2013 at 6:35 | comment | added | Serge |
You're probably right. My date is its own executable, but /bin/sed -> busybox.
|
|
| Oct 27, 2013 at 6:27 | comment | added | slm♦ |
@Serge - you're likely using a watered down version of these commands provided by BusyBox. If you look at the date command like so: ls -l /bin/date it's probably a link to an executable called busybox or something similar. These commands aren't full-featured, hence your problems.
|
|
| Oct 27, 2013 at 6:24 | comment | added | Serge |
I'm running /bin/sh on a QNAP device.
|
|
| Oct 27, 2013 at 6:21 | comment | added | Serge |
I simplified MOVEDIRSTR to: MOVEDIR=$(sed -r -e 's:([0-9]{4})([0-9]{2})([0-9]{2}).*:date -d \1-\2-\3 +"%Y/%m_%b/%d":' <<< "$line") It was necessary to keep tildas inside $(). Still no luck with date formatting though.
|
|
| Oct 27, 2013 at 6:06 | comment | added | slm♦ | @Serge - I had a typo with the setting of the variable. Please retry. Also are you using sh or bash? You tagged the Q as bash. | |
| Oct 27, 2013 at 6:05 | history | edited | slm♦ | CC BY-SA 3.0 |
deleted 1 characters in body
|
| Oct 27, 2013 at 5:56 | comment | added | Serge |
Quotation marks are not working for me for some reason. sh expands the date format as '+"%Y/%m' '%b/%d"'. Also, for some reason $() is not working and sh tries to execute =date, which does not exist. Here's the output I get when I try your suggested code: +++ sed -r -e 's:([0-9]{4})([0-9]{2})([0-9]{2}).*:date -d \1-\2-\3 +"%Y/%m %b/%d":' ++ =date -d 2013-10-27 '+"%Y/%m' '%b/%d"' ./dvrsnapshots.sh: line 25: =date: command not found +
|
|
| Oct 27, 2013 at 4:58 | history | answered | slm♦ | CC BY-SA 3.0 |