Outils pour utilisateurs

Outils du site


issue92:labo_linux_2

Ceci est une ancienne révision du document !


Table des matières

1

SSH is awesome. Tools like Midnight Commander (mc) are also really handy. Sadly, I’m a bit of a lazy admin and like to do some tasks graphically. A few days ago, I found that I needed to add text to the filename of a bunch of movies on my XBMC machine. I could have connected a keyboard and mouse to the machine (only an infrared receiver is connected to the USB port), logged out of the XBMC account, logged in to the openbox interface, and started renaming files, but I found a nice graphical tool to batch rename files. I just needed to figure a way to remotely mount the movie folder on our XBMC machine. The answer was the sshfs package. I use Xubuntu on most of my systems, and sshfs is not installed by default. Installing software is one job I prefer doing from the terminal, it’s just quicker: sudo apt-get install sshfs Mounting a remote partition is easy once sshfs is installed. But first I’ll make a directory to work from: mkdir ~/sftp

SSH est génial. Des outils tels que Midnight Commander (mc) sont également très pratiques. Malheureusement, je suis un administrateur un peu paresseux et j'aime faire certaines tâches graphiquement. Il y a quelques jours, j'ai eu besoin d'ajouter du texte au nom d'un tas de films sur ma machine XBMC. J'aurais pu connecter un clavier et une souris à la machine (il y a seulement un récepteur infrarouge connecté au port USB), me déconnecter du compte XBMC, me connecter à l'interface de openbox, et commencer à renommer les fichiers, mais j'ai trouvé un bel outil graphique pour renommer des fichiers par lot. J'avais juste besoin de trouver un moyen de monter à distance le dossier de films de notre machine XBMC.

La réponse a été le paquet sshfs. J'utilise Xubuntu sur la plupart de mes systèmes et sshfs n'est pas installé par défaut. L'installation de logiciel est une des actions que je préfère faire à partir du terminal, c'est vraiment plus rapide :

sudo apt-get install sshfs

Monter une partition distante est facile une fois sshfs installé. Mais d'abord je vais créer un répertoire à partir duquel je travaillerai :

mkdir ~/sftp

2

Now we’ll mount the remote file system. In this example, I’m going to use xbmc for the username on my XBMC remote server (which is called xbmc), and charles as my username on my local machine. Replace xbmc and charles with whatever username you use. sshfs xbmc@xbmc:/data/Movies /home/charles/sftp/ Notice that you do not have to sudo to mount the remote file system. You will, however, have to know the password for the user on the remote system. In this example, we mount the remote /data/Movies directory on the local /home/charles/sftp directory. You can also use the IP of your xbmc machine rather than the hostname. ssfs xbmc@192.168.1.10:/data/Movies /home/charles/sftp

Maintenant, nous allons monter le système de fichiers distant. Dans cet exemple, je vais utiliser xbmc comme nom d'utilisateur sur mon serveur distant XBMC (qui s'appele xbmc), et charles comme nom d'utilisateur sur ma machine locale. Remplacez xbmc et charles avec vos noms d'utilisateurs.

sshfs xbmc@xbmc:/data/Movies /home/charles/sftp/

Notez que vous n'avez pas besoin de sudo pour monter le système de fichiers distant. Cependant, vous aurez besoin de connaître le mot de passe de l'utilisateur sur le système distant. Dans cet exemple, nous montons les données du répertoire distant /data/Movies sur le répertoire local /home/charles/sftp/. Vous pouvez également utiliser l'adresse IP de votre machine xbmc plutôt que le nom d'hôte.

ssfs xbmc@192.168.1.10:/data/Movies /home/charles/sftp

3

Now that we have the remote system mounted, we need a program to rename the files. Of course you can do this with mv and regular expressions, but I find that I have a bad habit of messing up and forgetting to do something so I end up with botched filenames. There are a few graphical tools to rename files, but the one that worked best for me was gprename. One of the great features of gprename is the ability to preview your changes. I always preview changes in case I’ve messed up which letter/string to remove or add. Sometimes I also notice other things that also need changing while previewing. In the screenshot example, below, I started with the idea that I would replace the small and in Harry Potter and the … with a capital And, but after previewing I noticed that I should also capitalize the T in The – so the filename matches with the rest of the Harry Potter series. I made the change and previewed again before I clicked the Rename button.

4

Renaming is just one of the functions you can do with GPRename. Sometimes it’s nice to add or strip out text. I’ve started to differentiate some of my media by adding the text DVD or Blueray to the end of the file. Just switch to the Insert/Delete tab to add or remove text. Unfortunately, gprename doesn’t know where the end of the filename is and the extension begins so you have to count out where you want the text. In the next graphical example, I add “ - DVD” (a space, a dash, another space and the word DVD) to the 12th position in the filename. If you have lots of files with text in the same spot that you want to get rid of, you can select the delete option and choose which positions to delete between. For example, if you have a bunch of music files that begin 1. song_name.mp3, 2. songname.mp3, 3. songname.mp3 you would delete 0 to 2.

5

Once you’re done, don’t forget to close gprename – or sshfs might not be able to unmount the filesystem. You cannot simply umount ~/sftp. SSHfs uses fuse to mount the file system. To unmount ~/sftp use: fusermount -u ~/sftp Again you do not need to sudo because you’re mounting on your own home directory. GPrename also works with directories. Regular expressions are more handy, but if you haven’t learned regexp, or are worried about messing up your files, use gprename and preview before you rename.

issue92/labo_linux_2.1425500311.txt.gz · Dernière modification : 2015/03/04 21:18 de fredphil91