This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def auto_rename_exist_filename(file_path): | |
""" | |
For example: a.txt, a(1).txt, a(2).txt | |
Source: https://gist.github.com/nodewee/9ae9b0b461b4bcaf30bc2b84ca8c4743.js | |
""" | |
if not os.path.exists(file_path): | |
return file_path | |
dir_path = os.path.dirname(file_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def list_files( | |
dir: str, | |
ext: list or str = None, | |
recursive: bool = True, | |
excludes: list = None, | |
): | |
""" | |
Args: | |
- dir, directory path. | |
- ext, file extension list, lowercase letters, such as ".txt". Default is None, which means all files. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Copy text to clipboard (in the browser) | |
Updated: 2022-10-14 | |
Source: https://gist.github.com/NodeWee/a4df091ed6e4dc0e526e609daeb34cfd | |
*/ | |
async function copyTextToClipboard(text) { | |
// Reference: https://stackoverflow.com/a/30810322/1293256 | |
if (navigator.clipboard) { | |
// console.log('copy by navigator') |