<div dir="ltr">Alex,<div><br></div><div>I think I am too lazy to find the patterns...;)</div><div><br></div><div>Anyway, I managed to solve the original problem a different way. The issue that started me on this journey is that some of the .mkv files had been converted, and my original one liner was failing:</div><div><br></div><div><font face="monospace, monospace">find /media/plex/ -name "*.mkv" -exec ffmpeg -i {} -vcodec copy -acodec copy {}.mp4 > fix-mkv.txt 2>&1 \;</font><br></div><div><br></div><div>That is why I went to a multi-line script to find mkv files that had a corresponding mp4 file, and not convert those. Which brought me to the limitation on find looking for files with special characters. It seems find will 'find' them if the special characters are included in a wildcard, but won't find them unless they are escaped. </div><div><br></div><div>I looked through the ffmpeg man page and found that a "-y" option, which tells ffmpeg to always overwrite an existing file. My plex server has nothing better to do than consume electricity, so it can convert mkv files all day and night and overwrite already converted files without disturbing anyone. My new one liner:</div><div><br></div><div><font face="monospace, monospace">find /media/plex/ -name "*.mkv" -exec ffmpeg -i {} -y -vcodec copy -acodec copy {}.mp4 > fix-mkv.txt 2>&1 \;<br></font></div><div><br></div><div>Once it finishes and there are no errors in the fix-mkv.txt file, I will </div><div><br></div><div><font face="monospace, monospace">find /media/plex/ -name "*.mkv" -exec rm {} \;<br></font></div><div><br></div><div>and all the obnoxious mkv files will be gone with shiny new mp4 files in their place!</div><div><br></div><div>Thanks for the offer to help! I know I can spend hours crafting regex search patterns, and this issue really did not need that level of sophistication. In this case, a blunt hammer worked just as well as a sharp knife!</div><div><br></div><div>Mark</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 15, 2017 at 9:01 AM, Snyder, Alexander J <span dir="ltr"><<a href="mailto:alex@misteralexander.com" target="_blank">alex@misteralexander.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Sure there is! There is never a pattern <i>until we want a pattern</i>, then you'd be surprised at what pops up!<br><div><br></div><div>You might find that you need to process in groups (<i>ie: movies that have "(YYYY)" in the name and others that don't</i>).</div><div><br></div><div>Try this:</div><div><br></div><div><div>find /media/plex/ -type f -name "*.mkv" -exec bash -c "if [[ \"{}\" =~ (.*)(\[x264\])(.*) ]]; then echo \"{}\"; fi" \;</div></div><div><br></div><div>That should list all of your "x264" encoded movies, including your Disney movies used as an example above.</div><div><br></div><div>Feel free to ping me directly, so we can walk this out, step-by-step.</div><div><br></div><div>Interested to know the results. Let me know.</div><div><br></div><div>-Alex.</div><div><br></div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="m_4198818637325806151gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">--<br>Thanks,<br>Alex.</div></div><div dir="ltr"><br></div><div dir="ltr"><br></div></div></div></div></div></div></div></div><div><div class="h5">
<br><div class="gmail_quote">On Sun, Oct 15, 2017 at 8:25 AM, Mark Phillips <span dir="ltr"><<a href="mailto:mark@phillipsmarketing.biz" target="_blank">mark@phillipsmarketing.biz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Alex,<div><br></div><div>Thanks for the idea. However, there really aren't any common patterns in the 120 targets that I can match a regex to.</div><span class="m_4198818637325806151HOEnZb"><font color="#888888"><div><br></div><div>Mark</div></font></span></div><div class="m_4198818637325806151HOEnZb"><div class="m_4198818637325806151h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 15, 2017 at 8:20 AM, Snyder, Alexander J <span dir="ltr"><<a href="mailto:alex@misteralexander.com" target="_blank">alex@misteralexander.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">I did something very similar (BASH/find/ Plex) just the other day! The solution Aaron gave will fix it:<div dir="auto"><br></div><div dir="auto">"{}" instead of '{}'.</div><div dir="auto"><br></div><div dir="auto">May I also suggest matching the output to a regex pattern. That helps me sort with great precision:</div><div dir="auto"><br></div><div dir="auto">..... -exec bash -c "if [[ "{}" =~ (my)([pattern]{3}) ]]; then doThis; fi;" \;</div><div dir="auto"><br></div><div dir="auto">Let me know how it goes!<br><br><div data-smartmail="gmail_signature" dir="auto">Thanks,<br>Alex.<br><br>Sent from my Samsung Galaxy S8+</div></div></div><div class="m_4198818637325806151m_-6246999498070680584HOEnZb"><div class="m_4198818637325806151m_-6246999498070680584h5"><div class="gmail_extra"><br><div class="gmail_quote">On Oct 15, 2017 04:08, "Aaron Jones" <<a href="mailto:retro64xyz@gmail.com" target="_blank">retro64xyz@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div></div><div>Im just laying in bed, but try double quotes instead of singles and then paste me the exact error if you get one. </div><div><br>On Oct 14, 2017, at 10:15 PM, Mark Phillips <<a href="mailto:mark@phillipsmarketing.biz" target="_blank">mark@phillipsmarketing.biz</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">I found a few (~120) .mkv files crept into my plex movie drive. Plex on my limited plex server has trouble transcoding these files in real time, so I need to transcode them into mp4s ahead of time. <div><br></div><div>I tried this script, but I have an problem with the second find command.</div><div><br></div><div><div><font face="monospace, monospace">find /media/plex/ -name '*.mkv' | while read line; do</font></div><div><font face="monospace, monospace"> echo "Processing file '$line'"</font></div><div><font face="monospace, monospace"> f=`basename "$line" .mkv`</font></div><div><font face="monospace, monospace"> echo "basename = $f"</font></div><div><font face="monospace, monospace"> if [ -n "$(find /media/plex/ -name '$f.mp4' )" ]; then</font></div><div><font face="monospace, monospace"> #ffmpeg -i {} -vcodec copy -acodec copy $f.mp4 > fix2-mkv.txt 2>&1</font></div><div><font face="monospace, monospace"> #echo {} > files_fixed.txt 2>$1</font></div><div><font face="monospace, monospace"> echo "**************need to convert $line"</font></div><div><font face="monospace, monospace"> else</font></div><div><font face="monospace, monospace"> echo "$f.mp4 already exists"</font></div><div><font face="monospace, monospace"> fi</font></div><div><font face="monospace, monospace">done</font></div></div><div><br></div><div>All of the file names contain special characters, eg '[', and others. </div><div><br></div><div>For example,</div><div>/media/plex/Movies/Disney (Classic)/Robin Hood (1973 Movie) [x264-AAC][DVD][C-W].mkv<br></div><div><br></div><div>I get a false negative on this file when I search for the corresponding mp4 file because of the '[' in the file name. </div><div><br></div><div>This works:</div><div><div><font face="monospace, monospace">find /media/plex -name 'Robin Hood (1973 Movie)*'</font></div><div><font face="monospace, monospace">/media/plex/Movies/Disney (Classic)/Robin Hood (1973 Movie) [x264-AAC][DVD][C-W].mkv</font></div></div><div><br></div><div>but this gives a false negative</div><div><div><font face="monospace, monospace">find /media/plex -name 'Robin Hood (1973 Movie) [x264-AAC]*'</font></div><div><font face="monospace, monospace">root@orca:/home/mark# </font></div></div><div><br></div><div>I searched the find man page for ways to handle the special characters, but no luck on finding a solution. Anyone have a suggestion?</div><div><br></div><div>Thanks!</div><div><br></div><div>Mark</div></div>
</div></blockquote><blockquote type="cite"><div><span>------------------------------<wbr>---------------------</span><br><span>PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.or<wbr>g</a></span><br><span>To subscribe, unsubscribe, or to change your mail settings:</span><br><span><a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mail<wbr>man/listinfo/plug-discuss</a></span></div></blockquote></div><br>------------------------------<wbr>---------------------<br>
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.or<wbr>g</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" rel="noreferrer" target="_blank">http://lists.phxlinux.org/mail<wbr>man/listinfo/plug-discuss</a><br></blockquote></div></div>
</div></div><br>------------------------------<wbr>---------------------<br>
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.or<wbr>g</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" rel="noreferrer" target="_blank">http://lists.phxlinux.org/mail<wbr>man/listinfo/plug-discuss</a><br></blockquote></div><br></div>
</div></div><br>------------------------------<wbr>---------------------<br>
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.or<wbr>g</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" rel="noreferrer" target="_blank">http://lists.phxlinux.org/mail<wbr>man/listinfo/plug-discuss</a><br></blockquote></div><br></div></div></div>
<br>------------------------------<wbr>---------------------<br>
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org">PLUG-discuss@lists.phxlinux.<wbr>org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" rel="noreferrer" target="_blank">http://lists.phxlinux.org/<wbr>mailman/listinfo/plug-discuss</a><br></blockquote></div><br></div>