This script works fine when directly typed into the console:
N | find . -type f -iname "*.aac" -exec bash -c 'FILE="$1"; ffmpeg -i "${FILE}" -acodec libmp3lame "${FILE%.aac}.mp3";' _ '{}' \;
But as I'm trying to add it as an alias into my ~/.zshrc
file:
alias aac-to-mp3="N | find . -type f -iname \"*.aac\" -exec bash -c 'FILE=\"$1\"; ffmpeg -i \"${FILE}\" -acodec libmp3lame \"${FILE%.aac}.mp3\";' _ '{}' \;"
It yields:
✔ aac-to-mp3
_: N: command not found
ffmpeg version 4.4.1 Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 13.0.0 (clang-1300.0.29.3)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.4.1_3 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-avresample --enable-videotoolbox
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
: No such file or directory
I tried moving the N |
into the command itself:
alias aac-to-mp3="find . -type f -iname \"*.aac\" -exec bash -c 'FILE=\"$1\"; N | ffmpeg -i \"${FILE}\" -acodec libmp3lame \"${FILE%.aac}.mp3\";' _ '{}' \;"
But it generates the same output.
I did restart the shell between each alias change.
How do I make that script usable as an alias? I don't understand the issue.
N
? You can't pipe things tofind
, what is that supposed to do? – terdon Dec 22 '21 at 12:14bash
tag if it's aboutzsh
? – Stéphane Chazelas Dec 22 '21 at 13:09