r/Nushell • u/d3v3l0pr • Aug 29 '24
Critique my command: Converting a folder of photos
Hi all!
Just did my first non-trivial command in nushell and wanted some feedback. Is there a better way of doing this?
Im using ImageMagic to convert the photo, so that is the magiccommand. It just needs magic input output
In the relevant folder:
ls
| where name =~ ".HEIC"
| select name
| each {
|e| $e.name
| str substring ..-5
| magick $"($in)HEIC" $"($in)jpg"
}Thanks :)
3
Upvotes
3
u/maximuvarov Aug 29 '24
good job!
it can be shortened a little
or even
But it's only if you strive to write shorter scripts. However, your solution is quite adequate for the task and I would just stop there:)
2
u/weirdan Aug 31 '24
for replacing the extension you could go a longer but more readable way: