Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to rename directories? #17

Open
ashipunov opened this issue Jun 14, 2016 · 0 comments
Open

How to rename directories? #17

ashipunov opened this issue Jun 14, 2016 · 0 comments

Comments

@ashipunov
Copy link

This is an example:

$ mkdir 1
$ cd 1
$ touch {1,2,3,4,5}.txt
$ mkdir {6,7,8,9}
$ cp *txt 6
$ repren -n --renames --from "^" --to "aaa_" [6789]
Dry run: No files will be changed
Using 1 patterns:
  '^' -> 'aaa_'
Found 5 files in: 6, 7, 8, 9
- rename: 6/4.txt -> aaa_6/4.txt
- rename: 6/1.txt -> aaa_6/1.txt
- rename: 6/3.txt -> aaa_6/3.txt
- rename: 6/5.txt -> aaa_6/5.txt
- rename: 6/2.txt -> aaa_6/2.txt
Read 5 files (0 chars), found 0 matches (0 skipped due to overlaps)
Dry run: Would have changed 5 files (0 rewritten and 5 renamed)

$ repren --renames --from "^" --to "aaa_" [6789]
Using 1 patterns:
  '^' -> 'aaa_'
Found 5 files in: 6, 7, 8, 9
Traceback (most recent call last):
  File "/home/alexey/bin/repren", line 531, in <module>
    dry_run=options.dry_run)
  File "/home/alexey/bin/repren", line 406, in rewrite_files
    rewrite_file(path, patterns, do_renames=do_renames, do_contents=do_contents, by_line=by_line, dry_run=dry_run)
  File "/home/alexey/bin/repren", line 372, in rewrite_file
    counts = transform_file(transform, path, dest_path, by_line=by_line, dry_run=dry_run)
  File "/home/alexey/bin/repren", line 357, in transform_file
    move_file(source_path, dest_path, clobber=False)
  File "/home/alexey/bin/repren", line 299, in move_file
    shutil.move(source_path, dest_path)
  File "/usr/lib/python2.7/shutil.py", line 302, in move
    copy2(src, real_dst)
  File "/usr/lib/python2.7/shutil.py", line 130, in copy2
    copyfile(src, dst)
  File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 2] No such file or directory: 'aaa_6/4.txt'

So it is a bug plus feature request (rename folders only, or at least rename them like files)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant