File names with spaces in BASH

前端 未结 7 1332
清酒与你
清酒与你 2020-12-03 07:54

I\'m trying to write script that\'ll crop and resize large photos into HD Wallpapers.

#! /bin/bash


for i in `ls *.jpg`
do
    width=`identify -format \'%w         


        
相关标签:
7条回答
  • 2020-12-03 08:57

    I forgot to add the link if you want to download as txt file

    or just copy and paste this text as needed

    FIRST INSTALL

    apt-get install chromium-browser
    
    apt-get install omxplayer
    
    apt-get install terminator
    
    apt-get install nano (if not already installed)
    
    apt-get install zenity (if not already installed)
    

    THEN CREATE A BASH SCRIPT OF ALL OF THESE PERSONALLY WRITTEN SCRIPTS.

    MAKE SURE THAT EVERY SHELL SCRIPT IS A .sh FILE ENDING EACH ONE OF THESE IS SCRIPTED TO OPEN UP A DIRECTORY FOR YOU TO FIND AND PICK WHAT YOU WANT.

    IT RUNS A BACKGROUND TERMINAL & ALLOWS YOU TO CONTROL THE SONG OR MOVIE.

    MOVIE KEYS ARE AS FOLLOWS; p or space bar for pause, q for quit, - & + for sound up and down, left arrow and right arrow for skipping forward and back.

    MUSIC PLAYER REALLY ONLY HAS A SKIP SONG AND THAT IS CTRL+C AND IF THAT IS THE LAST SONG OR ONLY SONG THEN IT SHUTS DOWN AND THE TERMINAL GOES AWAY.

    ****INSTRUCTIONS TO MAKE THE SCRIPTS****

    • OPEN UP A TERMINAL

    • CD TO THE DIRECTORY YOU WANT THE SCRIPTS TO BE

      cd /home/pi/Desktop/
      
    • OPEN UP THE NANO EDITOR WITH THE TITLE OF SHELL YOU WANT

      sudo nano Movie_Player.sh
      
    • INSIDE NANO, TYPE OR COPY/PAST (REMEMBER THAT IN TERMINAL YOU NEED TO CTRL+SHIFT+V) THE SCRITP

    • SAVE THE DATA WITH CTRL+O

      ctrl+o
      
    • HIT ENTER TO SAVE AS THAT FILE NAME OR DELETE THE FILE NAME THEN TYPE NEW ONE JUST MAKE SURE IT ENDS IN .sh THEN HIT ENTER

    • NEXT YOU NEED TO SUDO CHMOD IT WITH +X TO MAKE IT CLICKABLE AS A BASH

      sudo chmod +x Movie_Player.sh
      
    • FINALLY RUN IT TO TEST EITHER BY DOUBLE CLICKING IT AND CHOOSING "EXECUTE IN TERMINAL" OR BY ./ IT IN TERMINAL

      ./Movie_Player.sh
      

    YOU ARE NOW GOOD TO PICK A MOVIE OR SELECT A SONG OR ALBUM AND ENJOY!

    **** ALL OF THESE SCRIPTS ACCOUNT FOR SPACES IN THE FILENAME

    SO YOU CAN ACCESS "TOM PETTY" OR "SIXTEEN STONE" WITHOUT NEEDING THE " _ " BETWEEN THE WORDS.

    -------WATCH A MOVIE SCRIPT ------- (

    #!/bin/bash
    
    FILE=`zenity --title "Pick a Movie" --file-selection`
    
    for FILE in "${FILE[0]}"
    
    do
         omxplayer "${FILE[0]}"
    done
    

    --------LISTEN TO A SONG -------

    #!/bin/bash
    
    FILE=`zenity --title "Pick a Song" --file-selection`
    
    for FILE in "${FILE[0]}"
    
    do
         play "${FILE[0]}"
    done
    

    --------LISTEN TO AN ALBUM ---------- SONGS IN ORDER

    #!/bin/bash
    
    DIR=`zenity --title "Pick a Album" --file-selection --directory` 
    
    for DIR in "${DIR[0]}"
    
    do
      cd "${DIR[0]}" && find . -type f -name '*.ogg' -o -name '*.mp3' | sort --version-sort | while read DIR; do
      play "$DIR"
      done
    done
    

    --------LISTEN TO AN ALBUM WITH SONGS IN RANDOM ORDER --------

    #!/bin/bash
    
    DIR=`zenity --title "Pick a Album" --file-selection --directory` 
    
    for DIR in "${DIR[0]}"
    
    do
      cd "${DIR[0]}" && find . -type f -name '*.ogg' -o -name '*.mp3' | while read DIR; do
      play "$DIR"
      done
    done
    
    0 讨论(0)
提交回复
热议问题