Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

Windows Server 2008 Server Core : Renaming a File with the Ren and Rename Commands, Sorting File Content with the Sort Utility

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
11/28/2012 4:23:46 PM

1. Renaming a File with the Ren and Rename Commands

The Ren and Rename commands both let you rename files and directories (the Microsoft documentation only mentions files, but the commands do work with directories). Using these commands is definitely faster than renaming them manually using Windows Explorer when you have a lot of files to change. These commands use the following syntax:

RENAME [drive:][path]filename1 filename2
REN [drive:][path]filename1 filename2

The following list describes each of the command line arguments.


drive

Specifies the drive to use for the file or directory. The default is to use the current drive.


path

Specifies the absolute or relative path to use for the file or directory. The default is to use the current directory. However, you can specify an absolute or relative path as needed. 


filename1

Defines the file or directory that you want to rename. You can use wildcard characters with this command. For example, if you want to rename all TXT files to have a TEXT extension, you'd type REN *.TXT *.TEXT and press Enter.

NOTE

Unlike in Windows Explorer, the Ren and Rename commands won't constantly ask you about file extension changes. Although this means you'll spend less time clicking the Yes button, it also means that you could accidentally rename files that you didn't want to rename.


filename2

Defines the new file or directory name. If you use a wildcard character for filename1, then you generally have to use a wildcard character with this argument as well. When in doubt, always test the renaming strategy using sample files.


2. Sorting File Content with the Sort Utility

The Sort utility is an amazing utility in that it can sort any text file. You can use this utility to perform analysis of output from other commands. For example, you could use it to perform a custom sort of a directory listing. The sort mechanism considers locale, so you can sort data based on a specific language. In addition, the Sort utility works on extremely large files, so you don't have to worry about getting halfway through a sort and having the sort fail. (Large sorts can take a while because the Sort utility writes any data that won't fit in memory to disk.) This utility uses the following syntax:

SORT [/R] [/+n] [/M kilobytes] [/L locale] [/REC recordbytes]
     [[drive1:][path1]filename1] [/T [drive2:][path2]] [/O
     [drive3:][path3]filename3]

The following list describes each of the command line arguments.


/+n

Specifies the comparison character. The default is to use the first character of each line as a starting point. By using another character as a starting point, you can change the sort order of the data. For example, the Dir command won't let you sort a directory listing by time without first sorting it by date. If you're interested in sorting the listing by time, you could set the sort to use the time, /+13, as the starting point for the sort. This particular sort is handy because some vendors, including Microsoft, have used the time as a method of indicating the version number of their DLLs. Consequently, sorting by the time can provide a very fast indication of version number as long as you know what the time indicator means (vendors often provide this information in their knowledge bases).

NOTE

There's no space between the /+ command line switch and the starting position of the sort. However, there's a space between the other command line switches and their arguments. Make sure you add or remove space as appropriate or the Sort utility will fail with an invalid command line switch error message.


/L[OCALE]
Local

Overrides the default system local, which is always the locale you selected for your Windows setup. Unfortunately, the only active override for Server Core is the C locale. The C locale provides a fast collating sort using binary differentiation, rather than language-specific sorting. Although this sort is quite fast, it might not always produce the results you need if your language uses diacritical marks. The sort is always case sensitive.


/M[EMORY]
Size

Defines the amount of memory in KB to use. Sort requires a minimum of 160 KB to perform its task. It's important to remember that the command window doesn't provide the same amount of memory as your machine contains. Generally, all modern machines have 640 KB of main memory available in the command window, with some memory used by command window components and some required by Sort itself. You can check the amount of available memory using the Mem utility . The only time you need to set the memory size is if Sort fails due to memory constraints. Sort uses 90 percent of available memory to maximize performance as a default.


/REC[ORD_MAXIMUM]
Characters

Defines the maximum number of characters in a record. The default size is 4,096 characters. However, you can specify up to 65,535 characters in a record. Larger record sizes use more memory for each record. Consequently, keeping the record size as small as possible will improve Sort efficiency.


/R[EVERSE]

Reverses the sort order. Instead of sorting A to Z, the output appears in Z to A order. Likewise, Sort also reverses number order.


drive1

Specifies the drive for the sort input. The default is the current drive when you specify a filename.


path1

Specifies the absolute or relative path to use for the sort input. The default is the current directory when you specify a filename.


filename1

Defines the name of the file that you want to sort. If you don't provide a filename, Sort will use the standard input device, which is usually the keyboard for Windows, as the input. You can change the standard input by using redirection , but providing a filename normally provides faster results.


/T[EMPORARY]
[drive2:][path2]

Determines the directory used to hold the temporary files for the sort. Normally, you don't need to use this command line switch because it's easier to use the system temporary directory (the default) for storage. However, you might want to use this option if the current drive is low on storage space or you want to use a faster drive to hold the temporary data to promote faster sorting.


/O[UTPUT]
[drive3:][path3]filename3

Specifies the location of the output. You must provide a filename as a minimum when using this command line switch. The drive3 and path3 arguments let you place the file on a different drive and directory. If you don't specify this command line switch, the Sort utility sends the output to the standard output, which is the console.

Other -----------------
- Windows Server 2008 Server Core : Moving Files and Renaming Files and Directories with the Move Command, Recovering Lost Files with the Recover Utility
- Windows Server 2008 : Moving Accounts with dsmove, Removing Objects with dsrm, Retrieving Information about Objects with dsquery
- Windows Server 2008 : Modifying Accounts with dsmod
- Designing and Configuring Unified Messaging in Exchange Server 2007 : Unified Messaging Shell Commands
- Designing and Configuring Unified Messaging in Exchange Server 2007 : Monitoring and Troubleshooting Unified Messaging (part 3) - Event Logs
- Designing and Configuring Unified Messaging in Exchange Server 2007 : Monitoring and Troubleshooting Unified Messaging (part 2) - Performance Monitors
- Designing and Configuring Unified Messaging in Exchange Server 2007 : Monitoring and Troubleshooting Unified Messaging (part 1) - Active Calls , Connectivity
- Working with the Windows Home Server Registry : Keeping the Registry Safe
- Working with the Windows Home Server Registry : Starting the Registry Editor, Navigating the Registry
- SharePoint 2010 : Building Composite Solutions (part 2) - External Data Search, External Data and User Profiles
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server