Package: replacefs
replacefsSearch and replace CLI tool for strings on the all systemThe replacefs tool permits to perform massive and controlled string replacements in files over the all file system in an intuitive and pleasant way. You will be able to replace a defined string to another recursively from a path, or locally in a defined path or in a list of files.InstallationWithpip:
sudopip3installreplacefs

Withyay:
yay-areplace

Withyaourt:
yaourt-areplaceCompatibilitypython >= 3Usagereplacefs[-h] [-l] [-r] [-s] [-a] [-c]
        [--initial_stringINITIAL_STRING]
        [--destination_stringDESTINATION_STRING]
        [--directory_pathFOLDER_PATH]
        [--file_paths_listFILE_PATH_01 FILE_PATH_02 ...]
        [--filename_must_end_byEND_STRING_01 END_STRING_02 ...]
        [--no_ask_confirmation] [--case_insensitive ]
        [--extension_filter] [--all_extensions]
        [--add_excluded_extensionsEND_STRING_01 END_STRING_02 ...]
        [--add_excluded_stringsSTRING_01 STRING_02 ...]
        [--excluded_pathsEXCLUDED_PATH_01 EXCLUDED_PATH_01 ...]
        [--binary_exclusion] [--binary_accepted]
        [--symlink_exclusion] [--symlink_accepted] [--end_param]options:-h, --helpshow this help message and exit-lperform local replacement inFOLDER_PATH. Enabled by default-rperform recursive replacement fromFOLDER_PATH-sperform specific replacement onFILE_PATH_01 FILE_PATH_02given by --list_files_paths_to_apply-a, --ask_confirmation, --askask for confirmation to perform replacement at anyINITIAL_STRINGoccurrence. Enabled by default-c, --case_sensitive, --case_respectrespect case when searching for occurrences. Enabled by default--initial_string, --initial, --init INITIAL_STRINGprecise the string to search and replace--destination_string, --destination, --dest DESTINATION_STRINGprecise the string to replace theINITIAL_STRINGstrings found--directory_path, --dirpath, --path FOLDER_PATHprecise the path of the directory to perform the replacement from--file_paths_list, --file_paths FILE_PATH_01 FILE_PATH_02 ...precise the list of file paths to perform the replacement on--filename_must_end_by, --end_by END_STRING_01 END_STRING_02 ...precise the list of acceptable end string to filter the files regarding their end names--no_ask_confirmation, --no_askenable no asking mode. Perform replacement without asking confirmation--case_insensitive, --no_case_respectenable case insensitive. Search forINITIAL_STRINGstring in insensitive case mode--extension_filter, --no_all_extensionsenable blacklist extension filter. The blacklist extension owns more than 60 audio, image and video extensions such as "mp3", "jpg" or "mp4". This mode is enabled by default--all_extensions, --no_extension_filterdisable blacklist extension filter.--add_excluded_extensions, --filter_extensions END_STRING_01 END_STRING_02 ...precise the unacceptable end strings to filter the files regarding their end names--add_excluded_strings, --filter_strings STRING_01 STRING_02 ...precise the unacceptable strings to filter the files regarding their names--excluded_paths EXCLUDED_PATH_01 EXCLUDED_PATH_01precise the paths to exclude when searching for theINITIAL_STRINGin the file system--binary_exclusion, --no_binaryrefuse binary files. Enabled by default--binary_accepted, --no_binary_exclusion, --binaryaccept binary files--symlink_accepted, --no_symlink_exclusion, --symlinkrefuse symlinks. Enabled by default--symlink_exclusion, --no_symlinkaccept symlinks-end_param, --endprecise the end of a parameter enumerationExamplesfor help:rp-h
or
replacefs--helplocalreplace "titi" occurrences to "toto" in current directory:rp-ltititoto.recursivereplace from the child directory "test":replacefs-rtititototestspecificreplace in the files "test01" "test/test02":replacefs-stititototest01test/test02Black list extensionsAll the extensions by default in the blacklist:"mp3", "MP3", "wav", "WAV", "m4a", "M4A", "aac", "AAC", "mp1", "MP1", "mp2", "MP2", "mpg", "MPG", "flac", "FLAC", "jpg", "JPG", "jpeg", "JPEG", "png", "PNG", "tif", "TIF", "gif", "GIF", "bmp", "BMP", "pjpeg", "PJPEG", "mp4", "MP4", "mpeg", "MPEG", "avi", "AVI", "wma", "WMA", "ogg", "OGG", "quicktime", "QUICKTIME", "webm", "WEBM", "mp2t", "MP2T", "flv", "FLV", "mov", "MOV", "webm", "WEBM", "mkv", "MKV", "class", "CLASS"use--all_extensionsor--no_extension_filterto disable blacklist extension filter.
use--add_excluded_extensionsor--filter_extensionsto add some moreSuggestionsSome useful bash functions with replace:functionreplace{#ex:  replace titi totonb_param="$#"if["$nb_param"-lt2];thenecho-e"\n\t$WARNINGneeds at least 2 strings arguments such as:\n\t\treplace titi toto"elif["$nb_param"-eq2];thenrp-l"$@".elif["$nb_param"-eq3];thenrp-l"$@"elif["$nb_param"-gt3];thenecho-e"$WARNINGspecific mode replace"rp-s"$@"fi}functionrplocal{replace$@;}functionrprecursive{#ex:  rprecursive titi totonb_param="$#"if["$nb_param"-lt2];thenecho-e"\n\t$WARNINGneeds at least 2 strings arguments such as:\n\t\treplace titi toto"elif["$nb_param"-eq2];thenrp-r"$@".elif["$nb_param"-eq3];thenrp-r"$@"elseecho-e"\n\t$WARNINGat  most 3 arguments ..."fi}functionrpcaseinsensitive{#ex:  rpcaseinsensitive titi totonb_param="$#"if["$nb_param"-lt2];thenecho-e"\n\t$WARNINGneeds at least 2 strings arguments such as:\n\t\treplace titi toto"elif["$nb_param"-eq2];thenrp--case_insensitive-l"$@".elif["$nb_param"-eq3];thenrp--case_insensitive-l"$@"elif["$nb_param"-gt3];thenecho-e"$WARNINGspecific mode replace"rp--case_insensitive-s"$@"fi}functionrpcaseinsensitivelocal{rpcaseinsensitive$@;}functionrprecursivecaseinsensitive{#ex:  rprecursivecaseinsensitive titi totonb_param="$#"if["$nb_param"-lt2];thenecho-e"\n\t$WARNINGneeds at least 2 strings arguments such as:\n\t\treplace titi toto"elif["$nb_param"-eq2];thenrp--case_insensitive-r"$@".elif["$nb_param"-eq3];thenrp--case_insensitive-r"$@"elseecho-e"\n\t$WARNINGat  most 3 arguments ..."fi}