1

Like I said, I have a a file with a colon in the filename, but I cannot do anything with it. How can I rename this file, exclude the colon?

$ ls -l
ls: 'Colossus:_The_Forbin_Project.mp4': No such file or directory
total 1998584
-rwxrwxrwx 1 501 501 2044545396 Mar 21  2013 Colossus:_The_Forbin_Project.mp4*

EDIT:

The filesystem is ext4

5
  • 1
    What kind of filesystem is this? Is the filesystem healthy? If NTFS, do you use ntfs-3g? or the kernel driver? Aug 31 '19 at 17:50
  • @KamilMaciorowski It is ext4
    – Brian
    Aug 31 '19 at 17:53
  • 1
    We need more information, on a ext4 system this isn't a problem under bash. As in I've just created a file with a colon in the name, moved it (to another file with a colon in the name). Both are perfectly listable, and valid. Aug 31 '19 at 18:07
  • 1
    There's definitely something odd going on if single quotes don't work to escape the colon. I'd consider unmounting the filesystem and running fsck on it.
    – dirkt
    Sep 1 '19 at 6:36
  • BTW: That's my favorite movie.
    – Greg Smith
    Sep 7 at 17:43
3

We would better comment, but we are not that reputed yet in order to be allowed to comment.

When one character cannot be accessed due to various reasons, one should first try escaping it with a backslash character ('\').

So, the first thing that I would try would be:

mv Colossus\:_The_Forbin_Project.mp4 'Your New Beautiful Name.mp4'

UPDATE:

On a second thought, there might be nothing happening there regarding the Colon Special Character (':'). What you did was just a simple ls -l, @Brian.

The Single Quotes have been used by the Operating System in order to signal an Error related to a certain 'Colossus:_The_Forbin_Project.mp4' Missing File.

What it really succeeds in listing is a File called as Colossus:_The_Forbin_Project.mp4*.

What does this mean?

It means that somehow you have created a File that contains the Special WildCard Character called as '*'. It can be replaced by any Number of Occurrences, including Zero, of any kind of Character. It is preferable to avoid it while naming Files.

What I would do as the Next Attempt in order to solve your Little Issue is to run the following Command:

mv Colossus\:_The_Forbin_Project.mp4\* Colossus_-_The_Forbin_Project.mp4

This escapes the Star Special Character and it removes it along with the Colon Special Character.

3
  • I'm not sure the colon being escaped, with the speech marks as well, makes sense. I'm going to do some testing, but I think you need to either escape it, or contain the string in speech marks. Aug 31 '19 at 18:05
  • 1
    True, @djsmiley2k . The New Name in the Example that is present above needs the Single Quotes due to the White Space Characters: 'Your New Beautiful Name.mp4'. There are No White Spaces in the Original Name that would require the presence of the Single Quotes. Good Catch!
    – user1018743
    Aug 31 '19 at 19:00
  • 1
    Ah yes I missed the change to spaces! : Aug 31 '19 at 19:36
2

Along the lines of what DOBRESCU_Mihai has suggested, you need to escape the colon it seems.

you could try:

mv Colossus\:_The_Forbin_Project.mp4 Colossus_The_Forbin_Project.mp4

Or

mv "Colossus:_The_Forbin_Project.mp4" "Colossus_The_Forbin_Project.mp4"

However I feel there maybe something 'worse' going on here than simply a bad filename. In my testing on ext4 with bash, I was able to create, move, rename a file with a colon in the name without escaping or surrounding it in speech marks, so this very much may depend on the filesystem you're working with. Update that information into your question and I'll attempt to answer for your specific file system.

0

Solved for me

What I did was plug the USB stick that the files were on that had the colon in to my android Smart phone, then I was able to rename the files taking out the colon, then I was able to copy the files in to the windows 10 pc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.