Contents
How to find a directory that does not contain a file?
The command that produces the right hand input to diff, printf “%s ” */*, just lists the album directories. The left hand command iterates through the *.cover paths and prints their directory names. Aha, the a/b and foo/bar directories have no cover.jpg.
Is there a file named file with spaces?
In dir with spaces, I created a file named file with spaces. As expected, since the directory dir with spaces contains the file named file with spaces it is not listed in the output. If I change the find command to have file4 in it, the output I get is,
What are names of files in Dir with spaces?
I created files file1, file2, file3 and file4 in dir2 and dir3. In dir1, I created file1, file2, file3. In dir with spaces, I created a file named file with spaces. As expected, since the directory dir with spaces contains the file named file with spaces it is not listed in the output.
Why does dir command ignore all subdirectories?
The problem is that if current directory contains subdirectory of that name, DIR command will be executed only within that subdirectory, ignoring other subdirectories.
Is the final Sed in the final directory?
The final sed is there to clean things up so you’re left with Artist/Album. This may or may not be desirable for you. This is much nicer to solve with globbing than with find. Now suppose you have no stray files in this nice structure. The current directory contains only artist subdirectories, and those contain only album subdirectories.
How to get the file name instead of the directory name?
You can use the -exec switch to run dirname and get the directory name instead of the file name. This has the added benefit of being POSIX compatible. This answer is shamelessly based on slm answer. It was an interesting approach, but it has a limitation if the file and/or directory names had special chars (space, semi-column…).
Is there a way to find multiple dirs in a file?
The first find operation could find multiple files for cover.* so there could be duplicate entries. sort -u quickly ruffles those down to one. The second find is always going to be unique. dirname is a handy tool for getting a file’s dir without resorting to sed (et al).
Why do my A / B directories have no cover.jpg?
Aha, the a/b and foo/bar directories have no cover.jpg. There are some broken corner cases, like that by default * expands to itself if it matches nothing. This can be addressed with Bash’s set -o nullglob. Will show all directories that do not have txt files in them.
How to list all file names from a folder?
In Excel, you can also use a formula to get the list of all filenames or psecifc type of filenames from a folder, please do with following steps: 1. Copy and paste the file path into a cell, and then type \\* after the file path as below screenshot shown: