Showing posts with label move file. Show all posts
Showing posts with label move file. Show all posts

Tuesday, February 7, 2017

VBScript Show Details Of a File, Copy, Delete And Move

set FSO = CreateObject("Scripting.FileSystemObject")

'Display detailed information about this file
set FileObject = FSO.GetFile("C:\tmp\heidisql.exe")

Wscript.Echo "Path = " & FileObject.Path
Wscript.Echo "Name = " & FileObject.Name
Wscript.Echo "Short Name = " & FileObject.ShortName
Wscript.Echo "Short Path = " & FileObject.ShortPath
Wscript.Echo "Drive = " & FileObject.Drive
Wscript.Echo "Size = " & FileObject.Size
Wscript.Echo "Attributes = " & FileObject.Attributes
Wscript.Echo "Parent Folder = " & FileObject.ParentFolder
Wscript.Echo "Date Created = " & FileObject.DateCreated
Wscript.Echo "Last Modified = " & FileObject.DateLastModified
Wscript.Echo "Last Accessed = " & FileObject.DateLastAccessed
'FileObject.Copy "heidisql_.exe", True 'True=Overwrite
'FileObject.Delete True 'True=Delete the read-only file
FileObject.Move "heidisql_moved.exe"

Tuesday, December 11, 2012

Move all files except one

File Structure:
/root/tmp/test
[root@dswing test]# ll
total 12
-rw-r--r-- 1 root root    2 Dec 12 13:41 a.txt
-rw-r--r-- 1 root root    4 Dec 12 13:42 b.txt
-rw-r--r-- 1 root root    0 Dec 12 13:43 c.txt
drwxr-xr-x 2 root root 4096 Dec 12 13:50 ks

Command:
find /root/tmp/test/ -maxdepth 1 -mindepth 1 -type f -not -name c.txt | grep -i txt$ | xargs -i cp -af {} /root/tmp/test/ks

Description:
-maxdepth 1 makes it not search recursively.  
-mindepth 1 makes it not include the /root/tmp/test/ path itself into the result.
-type f means search only for file type.
-not -name c.txt means all files except c.txt
grep -i txt$ means files name ends with txt.