EzDevInfo.com

filenames interview questions

Top filenames frequently asked interview questions

What is the significance of Windows file names that have hex numbers in them like {ED7BA470-8E54-465E-825C-99712043E01C}?

When doing a backup of my Windows hard drive, I noticed some file names that had a bunch of seemingly random numbers in them. For example: .{ED7BA470-8E54-465E-825C-99712043E01C}

Does that mean something special in Windows? What is the purpose of these files?


Source: (StackOverflow)

How do I delete a folder which is nested quite deep and avoid "File name too long"?

Eclipse created a temp folder in one of the directories which is nested quite deep, e.g.

dir1\dir1\dir1\dir1\...

I am unable to delete this folder in Windows via Explorer, the del or rmdir commands, nor the Cygwin 'rm' command. How should I remove this very long folder?

It just keeps saying "File name too long..."


Source: (StackOverflow)

Advertisements

What technical reasons exist for not using space characters in file names?

Somebody I know expressed irritation today regarding those of us who tend not to use spaces in our filenames, e.g. NamingThingsLikeThis.txt -- despite most modern operating systems supporting spaces in filenames.

Are there technical reasons that it's still common to see file names without (appropriate) spaces? If so, what are these technical reasons that spaces in filenames are avoided or discouraged, and in what circumstances are they relevant?

The most obvious reason I could think of, and why I typically avoid it, are the extra quotes required on the command line when dealing with such files. Are there any other significant technical reasons?


Source: (StackOverflow)

How can I rename a file whose name is in itself a full path (e.g. begins with "g:\")? [duplicate]

This question already has an answer here:

Inadvertently, I have created a file named g:\filename.csv on Windows XP through a Python script.

Note that g:\filename.csv is the filename. Actually it is saved on the F: drive.

I can't rename it using command prompt (ren oldfilename newfilename) or using F2 in an Explorer window. It says "can't read from drive" - Windows thinks the file is on the G: drive.

Is there any way to rename it?


Source: (StackOverflow)

What does the ~ mean in a file path?

What does the ~ mean in an absolute file path?

I see this in the output of things like build scripts but the path does not exist.


Source: (StackOverflow)

What characters are safe in cross-platform file names for Linux, Windows and OS-X

Currently, I use a YYMMDD-NAME+PAGE name for most of my files. NAME has spaces converted to underscores.

I'd like to use the YYYY-MM-DD date format, but I am not sure how to separate it from the name. A - would look strange if the name started with a number. If I use a _, then it conflicts with the underscore representing a space.

What characters are reasonably safe in file names that would work here? I am on Linux, but I might share files with other people (Windows 7, Mac OS X).


Source: (StackOverflow)

How to diff file names in two directories (without writing to intermediate files)?

I am trying to do something along the lines of:

diff `ls -1a ./dir1` `ls -1a ./dir2`

But that doesn't work for obvious reasons. Is there a better way of achieving this (in 1 line), than this?

ls -1a ./dir1 > lsdir1
ls -1a ./dir2 > lsdir2
diff lsdir1 lsdir2

Thanks


Source: (StackOverflow)

How would I go about creating a filename with invalid characters such as :?> ?

I need to do create a file with a filename such as :>?, is this possible somehow? Windows stops it.


Source: (StackOverflow)

Find files filtered by multiple extensions

What is the correct syntax for:

find . -type f -name \*.\(shtml\|css\)

This works, but is inelegant:

find . -type f -name \*.shtml > f.txt && find . -type f -name \*.css >> f.txt

How to do the same, but in fewer keystrokes?


Source: (StackOverflow)

How can I create a zip / tgz in Linux such that Windows has proper filenames?

Currently, tar -zcf arch.tgz files/* encodes filenames in UTF, so Windows users see all characters spoiled in filenames which are not english, and can do nothing with it.

zip -qq -r arch.zip files/* has the same behavior.

How can I create a zip / tgz archive so when Windows users extract it will have all filenames encoded properly?


Source: (StackOverflow)

Making BASH script `for` handle filenames with spaces (or workaround)

Whilst I have been using BASH for several years, my experience with BASH scripting is relatively limited.

My code is as below. It should grab the entire directory structure from within the current directory and replicate it into $OUTDIR.

for DIR in `find . -type d -printf "\"%P\"\040"`
do
  echo mkdir -p \"${OUTPATH}${DIR}\"        # Using echo for debug; working script will simply execute mkdir
  echo Created $DIR
done

The problem is, here is a sample of my file structure:

$ ls
Expect The Impossible-Stellar Kart
Five Iron Frenzy - Cheeses...
Five Score and Seven Years Ago-Relient K
Hello-After Edmund
I Will Go-Starfield
Learning to Breathe-Switchfoot
MMHMM-Relient K

Note the spaces :-S And for takes parameters word by word, so my script's output looks something like this:

Creating directory structure...
mkdir -p "/myfiles/multimedia/samjmusicmp3test/Learning"
Created Learning
mkdir -p "/myfiles/multimedia/samjmusicmp3test/to"
Created to
mkdir -p "/myfiles/multimedia/samjmusicmp3test/Breathe-Switchfoot"
Created Breathe-Switchfoot

But I need it to grab whole filenames (one line at a time) from the output of find. I have also tried making find put double-quotes around each filename. But this doesn't help.

for DIR in `find . -type d -printf "\"%P\"\040"`

And output with this changed line:

Creating directory structure...
mkdir -p "/myfiles/multimedia/samjmusicmp3test/"""
Created ""
mkdir -p "/myfiles/multimedia/samjmusicmp3test/"Learning"
Created "Learning
mkdir -p "/myfiles/multimedia/samjmusicmp3test/to"
Created to
mkdir -p "/myfiles/multimedia/samjmusicmp3test/Breathe-Switchfoot""
Created Breathe-Switchfoot"

Now, I need some way that I can iterate through like this, because I also wish to run a more complicated command involving gstreamer on each file in a following similar structure. How should I be doing this?

Edit: I need a code structure which will allow me to run multiple lines of code for each directory/file/loop. Sorry if I was unclear.

Solution: I initially tried:

find . -type d | while read DIR
do
  mkdir -p "${OUTPATH}${DIR}"
  echo Created $DIR
done

This worked fine for the most part. However, I later found that since the pipe results in the while loop running in a subshell, any variables set in the loop were later unavailable which made implementing an error counter quite difficult. My final solution (from this answer on SO):

while read DIR
do
  mkdir -p "${OUTPATH}${DIR}"
  echo Created $DIR
done < <(find . -type d)

This later allowed me to conditionally increment variables within the loop which would remain available later in the script.


Source: (StackOverflow)

Get bare file names recursively in command prompt

I ran into a little snag trying to get only the filenames (no extensions or file paths) recursively.This worked for me in the root folder:

dir /b

But when i added /s to scan recursively i also got file paths before filenames which i do not want. Is there a way to get bare filenames from all subfolders in a directory?

Im on Windows 7 x64 I'd rather use regular command prompt not PS or VBS


Source: (StackOverflow)

What does a blue filename in Windows Explorer mean?

I am viewing a network share where some filenames are in blue instead of black. I am using Windows 7.

This question mentions green filenames, which indicates encrypted file.

What does a blue filename indicate?


Source: (StackOverflow)

How do I recursively list filenames (only) in DOS/Windows? [duplicate]

Possible Duplicate:
Get bare file names recursively in command prompt

I would like to recursively list all files in a directory, showing filenames only (without extensions and without the full paths). I'm using Windows/DOS.

The closest I could get with dir was dir /s /b, but it lists full paths and also shows the extensions.

Well, perhaps I could live with the extensions, but I must get rid of the paths!

Any ideas?


Source: (StackOverflow)

Windows 7 file name length limited to 129 characters

I'm trying to properly name MP3s and I hit some arbitrary length of 129 characters (not 128?). NTFS supports 255 characters in file names, how do I fix this?

Star Wars - 6 - Return of the Jedi - 2 - 07 - Battle of Endor 2, Leia Is Wounded, The Duel Begins, Overtaking Bunker, Dark Si.mp3


Source: (StackOverflow)