# Button to move files in folder named from file

**URL:** https://resource.dopus.com/t/button-to-move-files-in-folder-named-from-file/8770
**Category:** Buttons/Scripts
**Tags:** commands, button
**Created:** [November 16, 2009, 9:40am UTC](https://resource.dopus.com/t/button-to-move-files-in-folder-named-from-file/8770 "2009-11-16T09:40:41Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![GoinPostal](https://resource.dopus.com/user_avatar/resource.dopus.com/goinpostal/32/26083_2.png) [@GoinPostal](https://resource.dopus.com/u/GoinPostal)
#### Post date: [November 16, 2009, 9:40am UTC](https://resource.dopus.com/t/button-to-move-files-in-folder-named-from-file/8770/1 "2009-11-16T09:40:41Z")

</div>

Here is a simple button to move selected files to a new folder based on the name of the first selected file. The folder name can be changed after the move command if shift key is held down.

The second button was already posted somewhere on this forum and move all files to the parent directory and delete the folder.

```auto
<?xml version="1.0"?>
<button backcol="none" display="both" separate="yes" textcol="none" type="three_button">
	<label>Déplacement Rapide</label>
	<icon1>#opentoolbar</icon1>
	<button display="both">
		<label>Déplacer dans un dossier auto</label>
		<tip>Déplacer dans un dossier du nom du fichier</tip>
		<icon1>#makedir</icon1>
		<function type="normal">
			<instruction>@nofilenamequoting </instruction>
			<instruction>@runonce @set Folder={file|noext}</instruction>
			<instruction>@runonce CREATEFOLDER &quot;{file|noext}&quot;</instruction>
			<instruction>Copy MOVE TO &quot;.\{$Folder}&quot;</instruction>
			<instruction>@keydown:shift </instruction>
			<instruction>Rename {$Folder}</instruction>
		</function>
	</button>
	<button backcol="none" display="both" textcol="none">
		<label>Déplacer dans le dossier parent</label>
		<tip>Déplacer les fichiers dans le dossier parent et supprimer le dossier counant</tip>
		<icon1>#opentoolbar</icon1>
		<function type="batch">
			<instruction>@set ChildPath={sourcepath$|noterm}</instruction>
			<instruction>@runmode hide</instruction>
			<instruction>Copy MOVE * TO ..</instruction>
			<instruction>Go ..</instruction>
			<instruction>rmdir {$ChildPath}</instruction>
		</function>
	</button>
</button>
```

Hope this can help!  
(sorry, tips are in french 😉)

---

_[View the full topic](https://resource.dopus.com/t/button-to-move-files-in-folder-named-from-file/8770)._
