Lorsque je déplace un seul fichier avec des espaces dans le nom de fichier, cela fonctionne comme ceci:
$ mv "file with spaces.txt" "new_place/file with spaces.txt"
Maintenant, j'ai une liste de fichiers pouvant contenir des espaces et je veux les déplacer. Par exemple:
$ echo "file with spaces.txt" > file_list.txt
$ for file in $(cat file_list.txt); do mv "$file" "new_place/$file"; done;
mv: cannot stat 'file': No such file or directory
mv: cannot stat 'with': No such file or directory
mv: cannot stat 'spaces.txt': No such file or directory
Pourquoi le premier exemple fonctionne-t-il, mais le second gouffre pas? Comment puis-je le faire fonctionner?
Au lieu d'écrire un script, vous pouvez utiliser ..
find -type f -iname \*.txt -print0 | xargs -IF -0 mv F /folder/to/destination/
pour le cas où les fichiers sont situés dans le fichier, vous pouvez procéder comme suit ::
cat file_with_spaces.txt | xargs -IF -0 mv F /folder/to/destination
le second n'est pas sûr si ..
Bonne chance
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
Fichier = zenity --title "Pick a Movie" --file-selection
pour fichier dans "$ {fichier [0]}"
do omxplayer "$ {fichier [0]}" fait
--------LISTEN TO A SONG -------
Fichier = zenity --title "Pick a Song" --file-selection
pour fichier dans "$ {fichier [0]}"
faire "$ {fichier [0]}" fait
--------LISTEN TO AN ALBUM ---------- SONGS IN ORDER
Dir = zenity --title "Pick a Album" --file-selection --directory
pour dir dans "$ {dir [0]}"
do cd "$ {dir [0]}" && trouver. -Type f -Name '. OGG' -O -O-Nom '. MP3' | Tri de tri | Pendant que lu dir; joue "$ dir" fait
--------LISTEN TO AN ALBUM WITH SONGS IN RANDOM ORDER --------
Dir = zenity --title "Pick a Album" --file-selection --directory
pour dir dans "$ {dir [0]}"
do cd "$ {dir [0]}" && trouver. -Type f -Name '. OGG' -O -O-Nom '. MP3' | Pendant que lu dir; joue "$ dir" fait