AMD LE-363 User's Podręcznik Użytkownika Strona 379

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 436
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 378
Chapter 18 Scripting XgOS Commands 353
Example: Move and Rename Files
cat /bin/mv
#> Rename files
/*
* (C) 2004,2005 XSIGO SYSTEMS Inc. All rights reserved. This material may not
* be reproduced, displayed, modified or distributed without the express prior
* written permission of the copyright holder.
*
* Author: David Allison
*
* $Id$
* $Date$
* $Revision$
* $Author$
*
* Description :
*/
if (args.size() < 2) {
throw "usage: mv file... dest"
}
var allfiles = []
for (var i = 0 ; i < args.size() - 1; i++) {
var files = glob (args[i])
foreach file files {
allfiles.append (file)
}
}
var dest = args[args.size() - 1]
var s = System.stat (dest)
var movetodir = false
if (s != null) {
if (s.S_ISDIR()) {
movetodir = true
}
}
if (allfiles.size() != 1 && !movetodir) {
throw "mv: Cannot move multiple files to a non-directory"
}
foreach file allfiles {
println ("moving " + file + " to " + dest)
Przeglądanie stron 378
1 2 ... 374 375 376 377 378 379 380 381 382 383 384 ... 435 436

Komentarze do niniejszej Instrukcji

Brak uwag