Remove .absolute_path thanks to fspath.
This commit is contained in:
parent
e9e1f5930c
commit
8c9588497c
9 changed files with 12 additions and 12 deletions
|
@ -115,7 +115,7 @@ def loop(pairs, dry=False):
|
||||||
line = f'{old.absolute_path}\n{new.absolute_path}\n'
|
line = f'{old.absolute_path}\n{new.absolute_path}\n'
|
||||||
safeprint.safeprint(line)
|
safeprint.safeprint(line)
|
||||||
else:
|
else:
|
||||||
os.rename(old.absolute_path, new.absolute_path)
|
os.rename(old, new)
|
||||||
|
|
||||||
def brename_argparse(args):
|
def brename_argparse(args):
|
||||||
return brename(
|
return brename(
|
||||||
|
|
|
@ -9,10 +9,10 @@ def main(argv):
|
||||||
for path in pathclass.glob_many(pipeable.go(argv, skip_blank=True)):
|
for path in pathclass.glob_many(pipeable.go(argv, skip_blank=True)):
|
||||||
if path.is_file:
|
if path.is_file:
|
||||||
pipeable.stdout(path.absolute_path)
|
pipeable.stdout(path.absolute_path)
|
||||||
os.remove(path.absolute_path)
|
os.remove(path)
|
||||||
elif path.is_dir:
|
elif path.is_dir:
|
||||||
pipeable.stdout(path.absolute_path)
|
pipeable.stdout(path.absolute_path)
|
||||||
shutil.rmtree(path.absolute_path)
|
shutil.rmtree(path)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -21,5 +21,5 @@ for path in pathclass.glob_many(argv):
|
||||||
newname = str(randname).rjust(12, '0') + path.dot_extension
|
newname = str(randname).rjust(12, '0') + path.dot_extension
|
||||||
randname += 1
|
randname += 1
|
||||||
newname = path.parent.with_child(newname)
|
newname = path.parent.with_child(newname)
|
||||||
os.rename(path.absolute_path, newname.absolute_path)
|
os.rename(path, newname)
|
||||||
print('%s -> %s' % (path.absolute_path, newname.basename))
|
print('%s -> %s' % (path.absolute_path, newname.basename))
|
||||||
|
|
|
@ -16,5 +16,5 @@ for path in pathclass.glob_many(argv):
|
||||||
newname = [random.choice(string.ascii_lowercase) for x in range(9)]
|
newname = [random.choice(string.ascii_lowercase) for x in range(9)]
|
||||||
newname = ''.join(newname) + path.dot_extension
|
newname = ''.join(newname) + path.dot_extension
|
||||||
newname = path.parent.with_child(newname)
|
newname = path.parent.with_child(newname)
|
||||||
os.rename(path.absolute_path, newname.absolute_path)
|
os.rename(path, newname)
|
||||||
print('%s -> %s' % (path.absolute_path, newname.basename))
|
print('%s -> %s' % (path.absolute_path, newname.basename))
|
||||||
|
|
|
@ -16,5 +16,5 @@ for path in pathclass.glob_many(argv):
|
||||||
newname = [random.choice(string.digits) for x in range(12)]
|
newname = [random.choice(string.digits) for x in range(12)]
|
||||||
newname = ''.join(newname) + path.dot_extension
|
newname = ''.join(newname) + path.dot_extension
|
||||||
newname = path.parent.with_child(newname)
|
newname = path.parent.with_child(newname)
|
||||||
os.rename(path.absolute_path, newname.absolute_path)
|
os.rename(path, newname)
|
||||||
print('%s -> %s' % (path.absolute_path, newname.basename))
|
print('%s -> %s' % (path.absolute_path, newname.basename))
|
||||||
|
|
|
@ -38,7 +38,7 @@ def filepull(pull_from='.', autoyes=False):
|
||||||
if autoyes or interactive.getpermission(f'Move {len(files)} files?'):
|
if autoyes or interactive.getpermission(f'Move {len(files)} files?'):
|
||||||
for f in files:
|
for f in files:
|
||||||
local = os.path.join('.', f.basename)
|
local = os.path.join('.', f.basename)
|
||||||
os.rename(f.absolute_path, local)
|
os.rename(f, local)
|
||||||
|
|
||||||
def filepull_argparse(args):
|
def filepull_argparse(args):
|
||||||
filepull(pull_from=args.pull_from, autoyes=args.autoyes)
|
filepull(pull_from=args.pull_from, autoyes=args.autoyes)
|
||||||
|
|
|
@ -24,7 +24,7 @@ def inputrename_argparse(args):
|
||||||
if this:
|
if this:
|
||||||
new_name = file.basename.replace(args.keyword, this)
|
new_name = file.basename.replace(args.keyword, this)
|
||||||
new_name = file.parent.with_child(new_name)
|
new_name = file.parent.with_child(new_name)
|
||||||
os.rename(file.absolute_path, new_name.absolute_path)
|
os.rename(file, new_name)
|
||||||
prev = this
|
prev = this
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -7,7 +7,7 @@ from voussoirkit import pipeable
|
||||||
def main(argv):
|
def main(argv):
|
||||||
for path in pathclass.glob_many(pipeable.go(argv, skip_blank=True)):
|
for path in pathclass.glob_many(pipeable.go(argv, skip_blank=True)):
|
||||||
pipeable.stdout(path.absolute_path)
|
pipeable.stdout(path.absolute_path)
|
||||||
send2trash.send2trash(path.absolute_path)
|
send2trash.send2trash(path)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -43,14 +43,14 @@ def sole_lift_argparse(args):
|
||||||
# to lift don't have name conflicts with the child dir itself.
|
# to lift don't have name conflicts with the child dir itself.
|
||||||
# Consider .\abc\abc where the grandchild can't be moved.
|
# Consider .\abc\abc where the grandchild can't be moved.
|
||||||
temp_dir = directory.with_child(passwordy.urandom_hex(32))
|
temp_dir = directory.with_child(passwordy.urandom_hex(32))
|
||||||
os.rename(child.absolute_path, temp_dir.absolute_path)
|
os.rename(child, temp_dir)
|
||||||
for grandchild in temp_dir.listdir():
|
for grandchild in temp_dir.listdir():
|
||||||
shutil.move(grandchild.absolute_path, directory.absolute_path)
|
shutil.move(grandchild, directory)
|
||||||
|
|
||||||
if temp_dir.listdir():
|
if temp_dir.listdir():
|
||||||
raise Exception()
|
raise Exception()
|
||||||
|
|
||||||
os.rmdir(temp_dir.absolute_path)
|
os.rmdir(temp_dir)
|
||||||
queue.append(directory.parent)
|
queue.append(directory.parent)
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
Loading…
Reference in a new issue