Timeline for How to create a script to make a structure and sort files by moving them into directories?
Current License: CC BY-SA 4.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 11, 2019 at 11:29 | history | edited | Kusalananda♦ | edited tags | |
| May 24, 2018 at 15:29 | answer | added | Kevin Lemaire | timeline score: 0 | |
| May 24, 2018 at 15:12 | comment | added | pLumo | Instead $(cut -d"-" -f1 $file | head -1) I'd use $(head -n 1 $file | cut -d"-" -f1) to avoid cutting all lines of the file (don't know how big the files are, maybe they are many gigabytes....). OR will it the unix magic stop the function anyways after head -1 ? If so, I' m definately wrong! But this for sure: better use head -n1 instead of deprecated head -1. | |
| May 24, 2018 at 15:10 | comment | added | Chris Davies | @RoVo that suggestion doesn't make any sense at all. Why would you want head when you're processing part of a single filename? | |
| May 24, 2018 at 14:51 | comment | added | pLumo | @roaima meant for file in ff* I guess. And you should place head before cut for better performance. | |
| May 24, 2018 at 14:50 | answer | added | oxdeca | timeline score: 0 | |
| May 24, 2018 at 14:36 | comment | added | Chris Davies | 1. Don't use for file in $(ls ff*) but use for file ff* instead. 2. Put your $variables into double quotes. For example mkdir "$test" instead of just mkdir $test. You will get an error if you try to create a directory that already exists. You can protect against that, or tell mkdir not to worry if it already exists with mkdir -p "$test". 3. In your first screenshot I can see only one file with a name starting with ff. 4. If the file starts with ff (line 7) it can't begin with a year (line 9).. Are you sure your requirements are correct? | |
| May 24, 2018 at 14:28 | comment | added | Chris Davies | Please don't post pictures of text. Copy and paste the text instead. This makes it far easier to read - and for us to copy and test. | |
| May 24, 2018 at 14:03 | review | First posts | |||
| May 24, 2018 at 14:36 | |||||
| May 24, 2018 at 13:58 | history | asked | Mantas | CC BY-SA 4.0 |