Skip to content

Instantly share code, notes, and snippets.

@wsaribeiro
Forked from andrashann/cl.sh
Created November 13, 2023 23:43
Show Gist options
  • Save wsaribeiro/49c477d5a65a68c4037eaa046dd3b003 to your computer and use it in GitHub Desktop.
Save wsaribeiro/49c477d5a65a68c4037eaa046dd3b003 to your computer and use it in GitHub Desktop.

Revisions

  1. @andrashann andrashann revised this gist Jan 11, 2023. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion cl.sh
    Original file line number Diff line number Diff line change
    @@ -44,9 +44,10 @@ exiftool "-createdate<filename" "-datetimeoriginal<filename" -overwrite_original
    # Shift all timestamps of pictures
    exiftool -AllDates-=1:10 -filemodifydate-=1:10 -P -overwrite_original *.jpg

    # Get back original file number (e.g. IMG_007.jpg from the FileNumber exif field and use as filename
    # Retrieve original file number (e.g. IMG_007.jpg from the FileNumber exif field and use as filename
    exiftool '-filename<$FileNumber.%e' *.jpg


    # FFMPEG

    # Combine image files as video
  2. @andrashann andrashann revised this gist Jan 11, 2023. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions cl.sh
    Original file line number Diff line number Diff line change
    @@ -18,6 +18,11 @@
    # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    # DEALINGS IN THE SOFTWARE.

    # RENAME

    # Replace a string in all file names in a folder
    rename 's/old/new/' *


    # EXIFTOOL

    @@ -36,6 +41,11 @@ exiftool '-DateTimeOriginal>FileModifyDate' foo.jpg
    # Modify EXIF creation date to match filename for files in this folder
    exiftool "-createdate<filename" "-datetimeoriginal<filename" -overwrite_original_in_place ./

    # Shift all timestamps of pictures
    exiftool -AllDates-=1:10 -filemodifydate-=1:10 -P -overwrite_original *.jpg

    # Get back original file number (e.g. IMG_007.jpg from the FileNumber exif field and use as filename
    exiftool '-filename<$FileNumber.%e' *.jpg

    # FFMPEG

  3. @andrashann andrashann revised this gist Dec 30, 2021. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions cl.sh
    Original file line number Diff line number Diff line change
    @@ -80,3 +80,9 @@ mp3info -p "%f: %m:%02s\n" *.mp3
    for file in *.mp3; do mp3info -p "%S\n" "$file"; done | paste -sd+ - | sed 's+\(.*\)+(\1)/60+' | bc
    # in hh:mm:ss format (https://stackoverflow.com/a/54541337)
    for file in *.mp3; do mp3info -p "%S\n" "$file"; done | paste -sd+ - | bc | dc -e '?1~r60~r60~r[[0]P]szn[:]ndZ2>zn[:]ndZ2>zn[[.]n]sad0=ap'


    # ZIP

    # remove mac-related files from zip archives
    zip -d filename.zip __MACOSX/\* \*/.DS_Store
  4. @andrashann andrashann revised this gist Oct 4, 2021. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion cl.sh
    Original file line number Diff line number Diff line change
    @@ -77,4 +77,6 @@ mp3info -p "%f: %m:%02s\n" *.mp3

    # Print the total length of all mp3 files in a folder (in minutes)
    # (corrected version of https://superuser.com/a/947201)
    for file in *.mp3; do mp3info -p "%S\n" "$file"; done | paste -sd+ - | sed 's+\(.*\)+(\1)/60+' | bc
    for file in *.mp3; do mp3info -p "%S\n" "$file"; done | paste -sd+ - | sed 's+\(.*\)+(\1)/60+' | bc
    # in hh:mm:ss format (https://stackoverflow.com/a/54541337)
    for file in *.mp3; do mp3info -p "%S\n" "$file"; done | paste -sd+ - | bc | dc -e '?1~r60~r60~r[[0]P]szn[:]ndZ2>zn[:]ndZ2>zn[[.]n]sad0=ap'
  5. @andrashann andrashann revised this gist Oct 4, 2021. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions cl.sh
    Original file line number Diff line number Diff line change
    @@ -74,3 +74,7 @@ java -jar mkgmap.jar --gmapsupp a.img b.img c.img typ.TYP

    # Print mp3 file names with track lengths of files in current folder
    mp3info -p "%f: %m:%02s\n" *.mp3

    # Print the total length of all mp3 files in a folder (in minutes)
    # (corrected version of https://superuser.com/a/947201)
    for file in *.mp3; do mp3info -p "%S\n" "$file"; done | paste -sd+ - | sed 's+\(.*\)+(\1)/60+' | bc
  6. @andrashann andrashann revised this gist Oct 7, 2020. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions cl.sh
    Original file line number Diff line number Diff line change
    @@ -36,6 +36,7 @@ exiftool '-DateTimeOriginal>FileModifyDate' foo.jpg
    # Modify EXIF creation date to match filename for files in this folder
    exiftool "-createdate<filename" "-datetimeoriginal<filename" -overwrite_original_in_place ./


    # FFMPEG

    # Combine image files as video
    @@ -62,7 +63,14 @@ youtube-dl -f 'bestaudio[ext=m4a]' 'http://youtu.be/videoid'
    # Convert all text to curves in PDF
    gs -o file-with-outlines.pdf -dNoOutputFonts -sDEVICE=pdfwrite input-file.pdf


    # MKGMAP

    # Combine multiple img files into one
    java -jar mkgmap.jar --gmapsupp a.img b.img c.img typ.TYP


    # MP3INFO

    # Print mp3 file names with track lengths of files in current folder
    mp3info -p "%f: %m:%02s\n" *.mp3
  7. @andrashann andrashann revised this gist Jun 10, 2020. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion cl.sh
    Original file line number Diff line number Diff line change
    @@ -60,4 +60,9 @@ youtube-dl -f 'bestaudio[ext=m4a]' 'http://youtu.be/videoid'
    # GHOSTSCRIPT

    # Convert all text to curves in PDF
    gs -o file-with-outlines.pdf -dNoOutputFonts -sDEVICE=pdfwrite input-file.pdf
    gs -o file-with-outlines.pdf -dNoOutputFonts -sDEVICE=pdfwrite input-file.pdf

    # MKGMAP

    # Combine multiple img files into one
    java -jar mkgmap.jar --gmapsupp a.img b.img c.img typ.TYP
  8. @andrashann andrashann revised this gist May 12, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions cl.sh
    Original file line number Diff line number Diff line change
    @@ -33,6 +33,8 @@ exiftool -all= foo.jpg
    # Modify file modification/creation date to match EXIF data
    exiftool '-DateTimeOriginal>FileModifyDate' foo.jpg

    # Modify EXIF creation date to match filename for files in this folder
    exiftool "-createdate<filename" "-datetimeoriginal<filename" -overwrite_original_in_place ./

    # FFMPEG

  9. @andrashann andrashann revised this gist May 12, 2020. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions cl.sh
    Original file line number Diff line number Diff line change
    @@ -42,6 +42,9 @@ cat *.jpg | ffmpeg -f image2pipe -r 24 -vcodec mjpeg -i - -vcodec libx264 out.mp
    # Trim video from -ss to length -t
    ffmpeg -i input.mp4 -ss 00:29:21 -t 00:02:26 -async 1 -c copy output.mp4

    # convert .mov from fcpx into much smaller mp4
    ffmpeg -i input.mov -c:v libx264 -c:a aac -strict experimental output.mp4


    # YOUTUBE-DL

  10. @andrashann andrashann revised this gist Jan 29, 2020. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions cl.sh
    Original file line number Diff line number Diff line change
    @@ -30,6 +30,9 @@ exiftool -ext jpg -ext mp4 '-filename<CreateDate' -d '%Y-%m-%d %H.%M.%S%%-c.%%e'
    # Delete all EXIF information
    exiftool -all= foo.jpg

    # Modify file modification/creation date to match EXIF data
    exiftool '-DateTimeOriginal>FileModifyDate' foo.jpg


    # FFMPEG

  11. @andrashann andrashann revised this gist Nov 25, 2019. 1 changed file with 21 additions and 0 deletions.
    21 changes: 21 additions & 0 deletions cl.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,24 @@
    # Copyright 2019 A. H.

    # Permission is hereby granted, free of charge, to any person obtaining a
    # copy of this software and associated documentation files (the "Software"),
    # to deal in the Software without restriction, including without limitation
    # the rights to use, copy, modify, merge, publish, distribute, sublicense,
    # and/or sell copies of the Software, and to permit persons to whom the
    # Software is furnished to do so, subject to the following conditions:
    #
    # The above copyright notice and this permission notice shall be included in
    # all copies or substantial portions of the Software.
    #
    # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
    # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    # DEALINGS IN THE SOFTWARE.


    # EXIFTOOL

    # Add coordinates to images in folder from gpx file
  12. @andrashann andrashann created this gist Nov 25, 2019.
    34 changes: 34 additions & 0 deletions cl.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    # EXIFTOOL

    # Add coordinates to images in folder from gpx file
    exiftool -P -overwrite_original -geotag=track.gpx /path/to/images

    # Name files according to EXIF date and timestamp
    exiftool -ext jpg -ext mp4 '-filename<CreateDate' -d '%Y-%m-%d %H.%M.%S%%-c.%%e' ../exiftool_test/

    # Delete all EXIF information
    exiftool -all= foo.jpg


    # FFMPEG

    # Combine image files as video
    cat *.jpg | ffmpeg -f image2pipe -r 24 -vcodec mjpeg -i - -vcodec libx264 out.mp4

    # Trim video from -ss to length -t
    ffmpeg -i input.mp4 -ss 00:29:21 -t 00:02:26 -async 1 -c copy output.mp4


    # YOUTUBE-DL

    # Download with subtitles
    youtube-dl url -o output.mp4 --write-sub

    # Download audio only from
    youtube-dl -f 'bestaudio[ext=m4a]' 'http://youtu.be/videoid'


    # GHOSTSCRIPT

    # Convert all text to curves in PDF
    gs -o file-with-outlines.pdf -dNoOutputFonts -sDEVICE=pdfwrite input-file.pdf