Skip to content

Instantly share code, notes, and snippets.

@uilianries
Created August 16, 2019 21:49
Show Gist options
  • Save uilianries/b6a50241ce65f2fdedb2cdaa0034597d to your computer and use it in GitHub Desktop.
Save uilianries/b6a50241ce65f2fdedb2cdaa0034597d to your computer and use it in GitHub Desktop.
Rename All image files
import os
import magic
if __name__ == "__main__":
files = []
path = "/home/uilian/Development/conan/docs"
# r=root, d=directories, f = files
for r, d, f in os.walk(path):
for file in f:
file_path = os.path.join(r, file)
if "image" in magic.from_file(file_path) or \
file.endswith(".png") or \
file.endswith(".jpg"):
print(f"Found {file}")
if file.startswith("conan-"):
continue
elif file.startswith("conan_"):
new_file = file.replace("conan_", "conan-")
new_path = os.path.join(r, new_file)
print(f"Rename {file_path} : {new_path}")
os.rename(file_path, new_path)
command = "find {} -type f -name '*.rst' | xargs sed -i 's/{}/{}/g'".format(
path, file.replace(".", r"\."), new_file)
os.system(command)
else:
new_file = "conan-" + file
new_path = os.path.join(r, new_file)
print(f"Rename {file_path} : {new_path}")
os.rename(file_path, new_path)
command = "find {} -type f -name '*.rst' | xargs sed -i 's/{}/{}/g'".format(
path, file.replace(".", r"\."), new_file)
os.system(command)
@tamecalm
Copy link

tamecalm commented Aug 16, 2019

Creating heroku-postgresql:hobby-dev on ⬢ adsvim... ⣾
(node:22785) [DEP0066] DeprecationWarning:Creating heroku-postgresql:hobby-dev on ⬢ adsvim... free
Database has been created and is available
 ! This database is empty. If upgrading, you can transfer
 ! data from another database with pg:copy
Created postgresql-symmetrical-93636 as HEROKU_POSTGRESQL_PURPLE_URL
Use heroku addons:docs heroku-postgresql to view documentation]

I tried installing the prostgresql database see error.. Help bro

Please help me why this error on the terminal

Sent from my W2 using FastHub

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