Rename a file in the Mxit user's gallery
        User authentication required with the following scope: 'content/write'
760415
def rename_gallery_file(self, file_id, new_file_name, scope='content/write'):
        
        return _put(
            token=self.oauth.get_user_token(scope),
            uri='/user/media/file/' + urllib.quote(file_id),
            data=new_file_name
        )
1167082
def action_rename(self, courseid, taskid, path, new_path):
        
        # normalize
        path = path.strip()
        new_path = new_path.strip()
        if not path.startswith("/"):
            path = "/" + path
        if not new_path.startswith("/"):
            new_path = "/" + new_path

        old_path = self.verify_path(courseid, taskid, path)
        if old_path is None:
            return self.show_tab_file(courseid, taskid, _("Internal error"))

        wanted_path = self.verify_path(courseid, taskid, new_path, True)
        if wanted_path is None:
            return self.show_tab_file(courseid, taskid, _("Invalid new path"))

        try:
            self.task_factory.get_task_fs(courseid, taskid).move(old_path, wanted_path)
            return self.show_tab_file(courseid, taskid)
        except:
            return self.show_tab_file(courseid, taskid, _("An error occurred while moving the files"))
1234548
def rename_script(rename=None):  # noqa: E501
    
    if connexion.request.is_json:
        rename = Rename.from_dict(connexion.request.get_json())  # noqa: E501

    if(not hasAccess()):
        return redirectUnauthorized()

    driver = LoadedDrivers.getDefaultDriver()
    if (not driver.renameScript(rename.original.name, rename.new.name)):
        return ErrorResponse(status=500, message='Cannot rename to an existing file.')
    return Response(status=200, body={'file-name': rename.new.name})
1024186
function mv(src, dist) {
      try {
        fs.renameSync(src, dist);
      }
      catch (e) {
        cp(src, dist);
        rm(src);
      }
    }
954555
function changeId(content, filePath, name, idSep) {
    if (idSep === void 0) { idSep = '_'; }
    var idReg = /svgicon(\w+)/g;
    content = content.replace(idReg, function (match, elId) {
        return "svgicon" + idSep + filePath.replace(/[\\\/]/g, idSep) + name + idSep + elId;
    });
    return content;
}
740775
def _update_asset_content_filename_on_disk_to_match_id(self, ac):
        """"""
        def has_secondary_storage():
            return 'secondary_data_store_path' in self._config_map

        datastore_path = ''
        secondary_data_store_path = ''

        if 'data_store_full_path' in self._config_map:
            datastore_path = self._config_map['data_store_full_path']
        if has_secondary_storage():
            secondary_data_store_path = self._config_map['secondary_data_store_path']
        relative_path = self._config_map['data_store_path']

        filepath = os.path.join(datastore_path, ac._my_map['url'])
        old_filename = os.path.splitext(os.path.basename(filepath))[0]
        new_path = filepath.replace(old_filename, ac.ident.identifier)
        os.rename(filepath, new_path)

        # Should also rename the file stored in the secondary path
        if has_secondary_storage():
            old_path = '{0}/repository/AssetContent'.format(relative_path)
            filepath = os.path.join(datastore_path, ac._my_map['url']).replace(old_path, secondary_data_store_path)
            old_filename = os.path.splitext(os.path.basename(filepath))[0]
            new_path = filepath.replace(old_filename, ac.ident.identifier)
            os.rename(filepath, new_path)
1215581
def rename(src, dst):
    '''
    
    '''
    src = os.path.expanduser(src)
    dst = os.path.expanduser(dst)

    if not os.path.isabs(src):
        raise SaltInvocationError('File path must be absolute.')

    try:
        os.rename(src, dst)
        return True
    except OSError:
        raise CommandExecutionError(
            'Could not rename \'{0}\' to \'{1}\''.format(src, dst)
        )
    return False
520249
function handleNameUpdate(newFilenameInputEl, fileId) {
        var newName = newFilenameInputEl.value,
            origExtension;

        if (newName !== undefined && qq.trimStr(newName).length > 0) {
            origExtension = getOriginalExtension(fileId);

            if (origExtension !== undefined) {
                newName = newName + "." + origExtension;
            }

            spec.onSetName(fileId, newName);
        }

        spec.onEditingStatusChange(fileId, false);
    }
316688
def container_rename_folder(object_id, input_params={}, always_retry=False, **kwargs):
    
    return DXHTTPRequest('/%s/renameFolder' % object_id, input_params, always_retry=always_retry, **kwargs)
892
public static void renamePath(FileSystem fs, Path oldName, Path newName, boolean overwrite) throws IOException {
    if (!fs.exists(oldName)) {
      throw new FileNotFoundException(String.format("Failed to rename %s to %s: src not found", oldName, newName));
    }
    if (fs.exists(newName)) {
      if (overwrite) {
        HadoopUtils.moveToTrash(fs, newName);
      } else {
        throw new FileAlreadyExistsException(
            String.format("Failed to rename %s to %s: dst already exists", oldName, newName));
      }
    }
    if (!fs.rename(oldName, newName)) {
      throw new IOException(String.format("Failed to rename %s to %s", oldName, newName));
    }
  }
548497
function write(filename, mtime, data) {
  var tempname = filename + '+';

  try {
    mkdirp(path.dirname(filename));
    fs.writeFileSync(tempname, toBuffer(data));
    fs.renameSync(tempname, filename);
    fs.utimesSync(filename, mtime, mtime);
  } catch (err) {
    // Try to remove tmp file on error.
    // Don't check if exists, just suppress errors
    try { fs.unlinkSync(tempname); } catch (__) {}

    throw err;
  }
}
242871
public function rename($name = '', $append = '', $prepend = '', $overwrite = false) {
        if (is_callable($name)) {
            $name = call_user_func_array($name, array($this->name(), $this));
        } else {
            $name = $name ?: $this->name();
        }

        // Add boundaries
        $name = (string) $prepend . $name . (string) $append;

        // Remove unwanted characters
        $name = preg_replace('/[^_\-\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]/imu', '-', $name);

        // Rename file
        $ext = $this->ext() ?: MimeType::getExtFromType($this->type(), true);
        $newName = $name;

        // Don't overwrite
        if (!$overwrite) {
            $no = 1;

            while (file_exists($this->dir() . $newName . '.' . $ext)) {
                $newName = $name . '-' . $no;
                $no++;
            }
        }

        $targetPath = $this->dir() . $newName . '.' . $ext;

        if (rename($this->path(), $targetPath)) {
            $this->reset($targetPath);

            return true;
        }

        return false;
    }
115887
def create_gallery_folder(self, folder_name, scope='content/write'):
        
        return _post(
            token=self.oauth.get_user_token(scope),
            uri='/user/media/' + urllib.quote(folder_name)
        )
495381
function replaceInFile (filename, regex, replacement) {
    log.bright.cyan ('Exporting exchanges →', filename.yellow)
    let contents = fs.readFileSync (filename, 'utf8')
    const newContents = contents.replace (regex, replacement)
    fs.truncateSync (filename)
    fs.writeFileSync (filename, newContents)
}
939331
function renameFile (oldFile, newFile) {
    if (!isFileRegistered(oldFile) || isFileRegistered(newFile)) { return undefined; }

    let item = fileRegistry[oldFile];

    item.file = newFile;

    fileRegistry[newFile] = item;

    delete fileRegistry[oldFile];
}
961512
function updateFile(filename, content, exists) {
	fs.mkdirpSync(path.dirname(filename));
	fs.writeFileSync(filename, content);
	log.added(`${exists ? 'Update' : 'Create'} ${filename}`);
}
1133117
function writeFileAtomic(filepath, data, cb) {

    var fullpath = u.join(self.path, filepath);
    var dir = path.dirname(fullpath);

    var tmppath = u.join(self.tmp, filepath);
    var tmpdir = path.dirname(tmppath);

    mkdirp(tmpdir, function(err) {
      if (err) return cb(err);

      mkdirp(dir, function(err) {
        if (err) return cb(err);

        fs.writeFile(tmppath, data, function(err) {
          if (err) return cb(err);

          fs.rename(tmppath, fullpath, function(err) {
            if (err) return cb(err);
            cb();
          });
        });
      });
    });
  }