Skip to content

Instantly share code, notes, and snippets.

@ssbozy
Last active May 2, 2022 15:09
Show Gist options
  • Save ssbozy/4d089f9462574c2fe026a90ad8d1d3a9 to your computer and use it in GitHub Desktop.
Save ssbozy/4d089f9462574c2fe026a90ad8d1d3a9 to your computer and use it in GitHub Desktop.
Renaming files using basename command.
#!/bin/bash
for file in *.md.html
do
mv "$file" "$(basename $file .md.html).html"
done
@ssbozy
Copy link
Author

ssbozy commented May 2, 2022

While using pandoc command in a script in a loop, I found that the html files generated from markdown filename extension usually append html after filename. An example can be something as follows. Using filename test.md, the generated html file is test.md.html. Since renaming files individually is a pain, I created the above script to fix that. I saw people use regex based renaming as well but I like this method.

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