How do you change the capitalization of filenames in Git?

Starting Git 2.0.1 (June 25th, 2014), a git mv will just work on a case-insensitive OS. See commit baa37bf by David Turner (dturner-tw). mv: allow renaming to fix case on case-insensitive filesystems “git mv hello.txt Hello.txt” on a case-insensitive filesystem always triggers “destination already exists” error, because these two names refer to the same path … Read more

android, How to rename a file?

In your code: Shouldn’t it be : File from = new File(directory, currentFileName); instead of File from = new File(directory, “currentFileName”); For safety, Use the File.renameTo() . But check for directory existence before renaming it! File dir = Environment.getExternalStorageDirectory(); if(dir.exists()){ File from = new File(dir,”from.mp4″); File to = new File(dir,”to.mp4″); if(from.exists()) from.renameTo(to); } Refer: http://developer.android.com/reference/java/io/File.html#renameTo%28java.io.File%29

Is rename() atomic?

Yes and no. rename() is atomic assuming the OS does not crash. It cannot be split by any other filesystem op. If the system crashes you might see a ln() operation instead. Also note, when operating on a network filesystem, you might get ENOENT when the operation succeeded successfully. Local filesystem can’t do that to … Read more

Enforce unique upload file names using django?

Use uuid. To tie that into your model see Django documentation for FileField upload_to. For example in your models.py define the following function: import uuid import os def get_file_path(instance, filename): ext = filename.split(‘.’)[-1] filename = “%s.%s” % (uuid.uuid4(), ext) return os.path.join(‘uploads/logos’, filename) Then, when defining your FileField/ImageField, specify get_file_path as the upload_to value. file = … Read more

Rename file of the Mediastore which is created by app in android 10. Working on Android API 30 but shows error in API 29

java.lang.IllegalArgumentException: Movement of content://media/external/file/116 which isn’t part of well-defined collection not allowed So it is for Android Q not allowed if you use the collection; Uri extUri = MediaStore.Files.getContentUri(MediaStore.VOLUME_EXTERNAL); But is is allowed for a ‘well-defined collection’ like: Uri extUri = MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL); // Use “Pictures/MyFolder” for RELATIVE_PATH I leave it to you to find other … Read more

Rename multiple files in Python [duplicate]

import os import glob files = glob.glob(‘year*.jpg’) for file in files: os.rename(file, ‘year_{}’.format(file.split(‘_’)[1])) The one line can be broken to: for file in files: parts = file.split(‘_’) #[abc, 2000.jpg] new_name=”year_{}”.format(parts[1]) #year_2000.jpg os.rename(file, new_name)

Get the Perl rename utility instead of the built-in rename

I can only speak for Debian. The two programs are called /usr/bin/rename.ul from the util-linux package (hence the .ul suffix) /usr/bin/prename from the perl package The actual rename command works via the /etc/alternatives mechanism, whereby /usr/bin/rename is a symlink to /etc/alternatives/rename /etc/alternatives/rename is a symlink to /usr/bin/prename The same problem has been bugging me on … Read more