Skip to content

Instantly share code, notes, and snippets.

@dPacc
Last active October 4, 2023 05:07
Show Gist options
  • Save dPacc/1f72cc5a2930602a9f5fa92f7800ab2d to your computer and use it in GitHub Desktop.
Save dPacc/1f72cc5a2930602a9f5fa92f7800ab2d to your computer and use it in GitHub Desktop.
Command folder names to csv

You can run this command in a shell from the directory that you want to get the names of the folder into a csv.

find . -maxdepth 1 -type d -name "MA*" | sed 's|./||' > folder-names.csv

What this does is it looks for any directories ('-type d') within your current location ('.') that start with 'MA' ('-name "MA"')*. The '-maxdepth 1' part just means we're only looking at the top level, and not diving down into subdirectories.

Once those directories are found, we strip out the './' at the beginning of each folder name using 'sed', and then we put all of these names into a file called 'folder-names.csv'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment