@files.act_noext_only
@files.act_basename_only
def track_correct(path):
    path = utils.resub(track_correct_resub, path)
    path = utils.resub(track_double_digit_resub, path)
    path = path.replace("_", " ")
    return path


if __name__ == "__main__":

    move_argparse(
        track_correct,
        description='converts many common track formats into my standard r"\d\d - title.mpr"',
        epilog="""EXAMPLES

    %(f)s '1. title.mp3' '11 title.mp3'
    #dry run
    #new names:
    # 01 - title.mp3
    # 11 - title.mp3

    %(f)s -D '1. title.mp3' '11 title.mp3'
    #not dry run

    find . -iname '*mp3' | %(f)s
    #act on multiple files
""",
    )
    bname_noext = utils.whitespaces_to_single_space(bname_noext)
    bname_noext = utils.remove_trailling_whitespace(bname_noext)
    bname_noext = utils.remove_heading_whitespace(bname_noext)

    return os.path.join(head, bname_noext + dotext)

if __name__ == '__main__':

    move_argparse(
        id3_to_basename,
        description="renaming using id3 tags",
        epilog="""Open up this file and modify id3_to_basename function if you want a custom rename.
Someday this will be implemented as parsing of a simple format string.

INSTALLATION ON UBUNTU

    sudo aptitude install id3tool

EXAMPLES

    find subdir -iname '*.mp3' | %(f)s
    #renames on the tree
""")







from cirosantilli.move_argparse import move_argparse
from cirosantilli import files

@files.act_basename_only
def rename_func(bname):
    return (unidecode.unidecode(bname)).lower()

if __name__ == '__main__':

    move_argparse(
            rename_func,
            description="rename with unidecode and then to lowercase",
            epilog="""
EXAMPLES

    %(f)s ÁÊÌÕÜ.txt Çß.txt
    #renames to "aeiou.txt" and "cb.txt"

    find . | %(f)s
    #renames paths found
""")









import os

import unidecode

from cirosantilli import files
from cirosantilli.move_argparse import move_argparse

if __name__ == '__main__':

    move_argparse(
            files.act_basename_only(unidecode),
            epilog="rename mutiple files with unidecode",
            description="""takes paths from stdin null separated and from arguments and adds them up.

EXAMPLES

    %(f)s 中国.txt 美国.txt
    #renames given paths to "zhong guo.txt" and "mei guo.txt", according to unidecode

    find . | %(f)s
    #renames paths found
""")








#!/usr/bin/env python

from cirosantilli import files
from cirosantilli.move_argparse import move_argparse

if __name__ == '__main__':

    move_argparse(
                files.act_basename_only(lambda s:s.lower()),
                add_act_noext_only=True,
            )










import os

from cirosantilli.move_argparse import move_argparse
from cirosantilli import utils
from cirosantilli import files

if __name__ == '__main__':

    move_argparse(
            files.act_basename_only(utils.nice_basename_stripped),
            description="corrects filenames that are forbidden" \
                "or highly unadvisable on Linux/Windows/Mac by stripping bad things if possible",
            epilog="""EXAMPLES

    %(f)s a:b;c -rf as..txt
    #dry run

    %(f)s -D a:b;c -rf as..txt
    #not Dry run
    #renames to "abc" "rf" and "as.txt"

    find . | %(f)s
    #acts on found files
""")







#!/usr/bin/env python

import re
import os.path

from cirosantilli import utils
from cirosantilli.move_argparse import move_argparse
from cirosantilli import files

@files.act_basename_only
def rename_func(path):
    return utils.whitespaces_to_single_space(path)

if __name__ == '__main__':

    move_argparse(rename_func)










    move_argparse(
        rename_func,
        func_arg_adders=[add_find,add_replace],
        func_arg_controller=controller,
        add_act_noext_only=True,
        add_act_full_path=True,
        description="renames multiple files using a python regex find replace pair",
        epilog="""
EXAMPLES

    %(f)s 'a(.+?)a' '\1' aBBBBa.txt 00a11aa22a.txt
        dry run
        renames to:
            BBBB.txt
            001122.txt

    %(f)s -D 'a(.*?)a' '\1' aBBBBa.txt 00a11ca22c.txt
        not Dry run: really renames!

    ls | %(f)s a b
        act current dir

    find . | %(f)s a b
        act on found items

    find . | %(f)s -I a b
        don't Ignore case (enabled by default)

    find . | %(f)s -E a b
        don't act on Extension
""")
from cirosantilli import utils
from cirosantilli.move_argparse import move_argparse
from cirosantilli import files

remove_track_resub = [re.compile(r"\d+ - "),""]

@files.act_basename_only
def rename_func(path):
    head, bname = os.path.split(path)
    new_bname = utils.resub(remove_track_resub, bname)
    return os.path.join(head, new_bname)

if __name__ == '__main__':

    move_argparse(
        rename_func,
        description="remove track numbers from songs in the format \"^\d - .\""
        epilog="""EXAMPLES

    %(f)s "01 - title.mp3" "1 - title.mp3"
    #dry run
    #renames to:
    #  title.mp3
    #  title.mp3

    %(f)s -D "01 - title.mp3" "1 - title.mp3"
    #not Dry run
""")