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

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

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.1425499766.txt.gz · Dernière modification : 2015/03/04 21:09 de fredphil91