Rename file in transfer.

        :param fmfile: file data from filemail containing fileid
        :param newname: new file name
        :type fmfile: ``dict``
        :type newname: ``str`` or ``unicode``
        :rtype: ``bool``
436665
def rename_file(self, fmfile, newname):
        

        if not isinstance(fmfile, dict):
            raise FMBaseError('fmfile must be a <dict>')

        method, url = get_URL('file_rename')

        payload = {
            'apikey': self.config.get('apikey'),
            'logintoken': self.session.cookies.get('logintoken'),
            'fileid': fmfile.get('fileid'),
            'filename': newname
            }

        res = getattr(self.session, method)(url, params=payload)
        if res.status_code == 200:
            self._complete = True
            return True

        hellraiser(res)
1054721
@Action(
            semantics = SemanticsOf.IDEMPOTENT
    )
    public ExcelModuleDemoToDoItemBulkUpdateManager changeFileName(final String fileName) {
        setFileName(fileName);
        return toDoItemExportImportService.newBulkUpdateManager(this);
    }
197301
def _convert_rename(self, fc):
        
        old = fc.old_path
        new = fc.new_path
        keep_old = self._path_to_be_kept(old)
        keep_new = self._path_to_be_kept(new)
        if keep_old and keep_new:
            fc.old_path = self._adjust_for_new_root(old)
            fc.new_path = self._adjust_for_new_root(new)
            return fc
        elif keep_old:
            # The file has been renamed to a non-interesting location.
            # Delete it!
            old = self._adjust_for_new_root(old)
            return commands.FileDeleteCommand(old)
        elif keep_new:
            # The file has been renamed into an interesting location
            # We really ought to add it but we don't currently buffer
            # the contents of all previous files and probably never want
            # to. Maybe fast-import-info needs to be extended to
            # remember all renames and a config file can be passed
            # into here ala fast-import?
            self.warning("cannot turn rename of %s into an add of %s yet" %
                (old, new))
        return None
654244
def rename(self, new_name, range=None):
        """"""
        self.log.debug('rename: in')
        if not new_name:
            new_name = self.editor.ask_input("Rename to:")
        self.editor.write(noautocmd=True)
        b, e = self.editor.word_under_cursor_pos()
        current_file = self.editor.path()
        self.editor.raw_message(current_file)
        self.send_refactor_request(
            "RefactorReq",
            {
                "typehint": "RenameRefactorDesc",
                "newName": new_name,
                "start": self.get_position(b[0], b[1]),
                "end": self.get_position(e[0], e[1]) + 1,
                "file": current_file,
            },
            {"interactive": False}
        )
1350847
def rename_file(self, old_save_name, new_save_name, new_path):
        
        if old_save_name in self._files:
            del self._files[old_save_name]
        self.update_file(new_save_name, new_path)
370141
def change_filename(filehandle, meta):
    
    filename = secure_filename(meta.get('filename', filehandle.filename))
    basename, _ = os.path.splitext(filename)
    meta['original_filename'] = filehandle.filename
    filehandle.filename = filename + '.jpg'
    return filehandle
334813
function renameFile(from, to) {
  return new Promise((resolve, reject) => {
    fs.rename(from, to, (err) => {
      if (err) {
        reject(err);
        return;
      }
      resolve(to);
    });
  });
}
471393
def copy(self, new_fn):
        """"""
        new_file = self.__class__(fn=str(new_fn))
        new_file.write(data=self.read())
        new_file.utime(self.atime, self.mtime)
        return new_file
974470
@Override
    protected void doRename(final FileObject newfile) throws Exception {
        AludraLocalFile newLocalFile = (AludraLocalFile) FileObjectUtils.getAbstractFileObject(newfile);

        if (!file.renameTo(newLocalFile.getLocalFile())) {
            throw new FileSystemException("vfs.provider.local/rename-file.error", new String[] { file.toString(),
                    newfile.toString() });
        }
    }
845412
def rename(self, new_name):
        
        payload = {
            'new_name': new_name
        }
        data = json.dumps(payload)
        req = self.request(self.mist_client.uri+'/keys/'+self.id, data=data)
        req.put()
        self.id = new_name
        self.mist_client.update_keys()
12852
def file_name(self, file_name):
        
        if not self.can_update():
            self._tcex.handle_error(910, [self.type])

        self._data['fileName'] = file_name
        request = {'fileName': file_name}
        return self.tc_requests.update(self.api_type, self.api_sub_type, self.unique_id, request)
735217
def rename(self, newpath):
        ""
        # POST https://www.jottacloud.com/jfs/**USERNAME**/Jotta/Sync/Ny%20mappe?mvDir=/**USERNAME**/Jotta/Sync/testFolder
        #url = '%s?mvDir=/%s%s' % (self.path, self.jfs.username, newpath)
        params = {'mvDir':'/%s%s' % (self.jfs.username, newpath)}
        r = self.jfs.post(self.path,
                          extra_headers={'Content-Type':'application/octet-stream'},
                          params=params)
        return r
156047
def rename(*args):
    
    parser = argparse.ArgumentParser(prog="%s %s" % (__package__, rename.__name__), description=rename.__doc__)
    parser.add_argument('OLD_FILENAME', help="old file name", nargs='+')
    parser.add_argument('NEW_FILENAME', help="new file name", nargs=1)
    args = parser.parse_args(args)

    def _rename(config, old_name, new_name):
        old_path = os.path.realpath(old_name)
        old_key = os.path.relpath(old_path, config.root)
        new_path = os.path.realpath(new_name)
        new_key = os.path.relpath(new_path, config.root)
        if old_key not in config['files']:
            yield "Could not rename '%s', it is not being tracked" % old_name
        elif new_key in config['files']:
            yield "Could not rename '%s' to '%s', '%s' is already being tracked" % (old_name, new_name, new_name)
        elif os.access(old_path, os.W_OK|os.R_OK) and os.access(new_path, os.W_OK|os.R_OK):
            yield "Could not rename '%s' to '%s', both files already exist" % (old_name, new_name)
        elif not os.access(old_path, os.W_OK|os.R_OK) and not os.access(new_path, os.W_OK|os.R_OK):
            yield "Could not rename '%s' to '%s', neither file exists" % (old_name, new_name)
        else:
            new_sha = _file_key(new_key)
            os.rename(os.path.join(config.directory, config['files'][old_key]), os.path.join(config.directory, new_sha))
            config['files'][new_key] = new_sha
            del config['files'][old_key]
            if os.access(old_path, os.W_OK|os.R_OK):
                os.rename(old_path, new_path)

    config = FragmentsConfig()
    dest_path = os.path.relpath(args.NEW_FILENAME[0])
    dest_isdir = os.path.isdir(dest_path)
    if len(args.OLD_FILENAME) > 1 and not dest_isdir:
        yield "Could not rename multiple files, '%s' is not a directory." % os.path.relpath(dest_path)
        return

    for src_path in args.OLD_FILENAME:
        if os.path.isdir(src_path):
            old_names = list(_iterate_over_files([src_path], config, statuses='MDA '))
            if os.access(dest_path, os.R_OK):
                os.rename(src_path, os.path.join(dest_path, src_path))
                for s, path in old_names:
                    old_name = os.path.relpath(path)
                    new_name = os.path.join(dest_path, old_name)
                    for y in _rename(config, old_name, new_name):
                        yield y
            else:
                os.rename(src_path, dest_path)
                for s, path in old_names:
                    old_name = os.path.relpath(path)
                    new_name = os.path.join(dest_path, old_name[len(src_path)+1:])
                    for y in _rename(config, old_name, new_name):
                        yield y
        else:
            old_name = os.path.relpath(src_path)
            if dest_isdir:
                new_name = os.path.join(dest_path, os.path.basename(src_path))
            else:
                new_name = dest_path
            for y in _rename(config, old_name, new_name):
                yield y

    config.dump()
130587
protected function rename_file($fileid, $newname) {
        $result = $this->boxclient->rename_file($fileid, $newname);
        if (!empty($result->type) && $result->type == 'error') {
            $bits = explode('.', $newname);
            $suffix = '';
            if (count($bits) == 1) {
                $prefix = $newname;
            } else {
                $suffix = '.' . array_pop($bits);
                $prefix = implode('.', $bits);
            }
            $newname = $prefix . ' (' . date('Y-m-d H-i-s') . ')' . $suffix;
            $result = $this->boxclient->rename_file($fileid, $newname);
            if (empty($result->type) || $result->type != 'error') {
                return true;
            } else {
                // We could not rename the file for some reason...
                debugging('Error while renaming the file on Box.net', DEBUG_DEVELOPER);
            }
        } else {
            return true;
        }
        return false;
    }
1224902
function RenameFile($type, $dir, $filename, $newname)
    {
        $dir = $this->AccessDir($dir, $type);
        if (!$dir)
        {
            return false;
        }

        $filename = trim($filename);

        if (empty($filename))
        {
            return 'error';
        }

        if (!is_dir($dir . '/.thumbs'))
        {
            return 'error';
        }

        $dbfile = $dir . '/.thumbs/.db';
        if (is_file($dbfile))
        {
            $dbfilehandle = fopen($dbfile, "r");
            $dblength = filesize($dbfile);
            if ($dblength > 0)
            {
                $dbdata = fread($dbfilehandle, $dblength);
            }
            else
            {
                $dbdata = '';
            }
            fclose($dbfilehandle);
        }
        else
        {
            return 'error';
        }

        $files = unserialize($dbdata);

        foreach ($files as $file => $fdata)
        {
            if ($file == $filename)
            {
                $files[$file]['general']['name'] = $newname;
                break;
            }
        }

        $dbfilehandle = fopen($dbfile, "w");
        fwrite($dbfilehandle, serialize($files));
        fclose($dbfilehandle);

        return 'ok';
    }
492494
public void rename(String oldName, String newName)
        throws IOException, ServerException {
        if (oldName == null || newName == null) {
            throw new IllegalArgumentException("Required argument missing");
        }
        Command cmd = new Command("RNFR", oldName);
        try {
            Reply reply = controlChannel.exchange(cmd);
            if (!Reply.isPositiveIntermediate(reply)) {
                throw new UnexpectedReplyCodeException(reply);
            }
            controlChannel.execute(new Command("RNTO", newName));
        } catch (FTPReplyParseException rpe) {
            throw ServerException.embedFTPReplyParseException(rpe);
        } catch (UnexpectedReplyCodeException urce) {
            throw ServerException.embedUnexpectedReplyCodeException(
                                urce,
                                "Server refused renaming file");
        }
    }
1087531
public function rename($old_file, $new_file, $move = false)
	{
		if ( ! $this->_is_conn())
		{
			return false;
		}

		$result = @ftp_rename($this->_conn_id, $old_file, $new_file);

		if ($result === false)
		{
			if ($this->_debug == true)
			{
				$msg = ($move == false) ? 'Unable to rename' : 'Unable to move';

				throw new \FtpFileAccessException($msg);
			}
			return false;
		}

		return true;
	}