Timeline for Remove file-name extension, if it exists
Current License: CC BY-SA 4.0
17 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 22, 2019 at 12:42 | comment | added | DavRog | Thanks so much, really appreciate your help! | |
| Jan 22, 2019 at 12:28 | history | edited | Kusalananda♦ | CC BY-SA 4.0 | added 236 characters in body |
| Jan 22, 2019 at 12:18 | comment | added | Kusalananda♦ | @DavRog Ah, I see it now. The variable $file will contain the whole path to the file, not just the filename. This is good and proper, but it also means that you don't have to prepend the path in the [ -e ... ] test. That should be just [ -e "$file" ] (as in my code). | |
| Jan 22, 2019 at 12:17 | comment | added | DavRog | Thanks again @Kusalananda. Comments understood and renaming the variables certainly fixes the errors that were occurring but it doesn't actually rename the files. As I mentioned, the mv command was working fine before I added the variables so it's possible I have inadvertently changed something else that prevents it from removing the .xfr extension. | |
| Jan 22, 2019 at 12:16 | history | edited | Kusalananda♦ | CC BY-SA 4.0 | added 4 characters in body |
| Jan 22, 2019 at 12:04 | comment | added | Kusalananda♦ | @DavRog See addition to answer. | |
| Jan 22, 2019 at 12:04 | history | edited | Kusalananda♦ | CC BY-SA 4.0 | added 514 characters in body |
| Jan 22, 2019 at 11:57 | comment | added | DavRog | @Kusalananda - thanks for checking in again, I have updated the question, hopefully makes sense. Apologies for my ignorance, all very new to this | |
| Jan 22, 2019 at 11:28 | comment | added | Kusalananda♦ | @DavRog Please update your question with what you currently are attempting to do and I'll update the answer accordingly. | |
| Jan 22, 2019 at 11:20 | comment | added | DavRog | Firstly, thank you for your comments and apologies for the delay in reply. The mv operation - mv "$file" "${file%.xfr}" - was working fine until I added variables for the the file path location. Would that need to change now the directory path and filename is not hard-coded? | |
| Jan 22, 2019 at 11:14 | comment | added | DavRog | Firstly, thank you for your comments and apologies for the delay in reply. | |
| Jan 11, 2019 at 13:00 | history | edited | Kusalananda♦ | CC BY-SA 4.0 | added 3 characters in body |
| Jan 11, 2019 at 12:48 | comment | added | Kusalananda♦ | @Alexander Two reasons: 1) I prefer writing solutions that are portable (-v is a non-standard option for mv), and 2) The user may want to output a custom text for each file, as they do in the question. | |
| Jan 11, 2019 at 12:44 | comment | added | Alexander | why don't use mv -v instead of echo ? | |
| Jan 11, 2019 at 10:41 | history | edited | Kusalananda♦ | CC BY-SA 4.0 | added 82 characters in body |
| Jan 11, 2019 at 10:33 | history | edited | Kusalananda♦ | CC BY-SA 4.0 | added 82 characters in body |
| Jan 11, 2019 at 10:27 | history | answered | Kusalananda♦ | CC BY-SA 4.0 |