summaryrefslogtreecommitdiff
path: root/shell/bin/mv.php
blob: 8fc35cdbd8bc2ccc49451918d8b94001837721ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
class p_mv extends prog {
	public static main($args, $env) {
		$me = array_shift($args);
		if (count($args)>2) {
			$dest = array_pop($args);
			if (!is_dir($dest) {
				echo $me.': dest must be a directory: `'.$dest."'\n";
				return 1;
			}
			foreach ($args as $src) {
				rename($src,$dest.'/'.basename($src));
			}
		} elseif (count($args)==2) {
			rename($args[0],$args[1]);
		} else {
			echo 'Usage: '.$me." SOURCE [SOURCE2 [SOURCE3 ...]] DEST\n";
			return 1;
		}
	}
}