Memory Usage of the c directory files in cmd - cmd

So, im running dir c:\ in command prompt and it shows me,
dir c:\
Volume in drive C is OS
Volume Serial Number is BE7A-83CF
Directory of c:\
12/06/2012 04:48 PM Accumedic
02/10/2016 10:27 AM 221,431 avgremover.log
12/23/2015 01:44 AM 3,072 Datacollectors.db
05/08/2012 05:45 PM DELL
02/18/2011 11:46 AM Drivers
02/02/2012 02:17 PM 23,760 FLBS1601.TEST
02/02/2012 02:29 PM 23,760 FLBS1602.TEST
02/18/2011 11:46 AM Install
02/06/2012 11:48 AM 22 Network.bat
07/13/2009 11:20 PM PerfLogs
02/01/2016 03:27 PM Program Files
10/14/2015 03:05 PM Program Files (x86)
12/27/2011 01:34 PM Projects
05/04/2016 08:52 AM SQL_Docs
04/07/2014 04:30 PM temp
07/23/2015 11:19 AM Users
05/04/2016 08:47 AM Windows
5 File(s) 272,045 bytes
12 Dir(s) 1,979,822,080 bytes free
Is there a command to see the disk usage of each of the files, instead of just the total? Preferably, in a similar format, and not individually looking each one up.

It is showing you the sizes of the files in the directory. From your question:
02/10/2016 10:27 AM 221,431 avgremover.log
12/23/2015 01:44 AM 3,072 Datacollectors.db
This is telling you that avgremover.log is 221,431 bytes in size. Most of the lines in your example don't have a number because they are directories. dir doesn't list a size for them.

Related

Copy short 8.3 filename in long mode (Windows)

Trying to copy from command line a file named "SCOOTE~1.txt" to a folder where there is a file called "Scooter - Cosmos.txt".
The problem is that copy will contract the name of "Scooter - Cosmos.txt" to "Scoote~1.txt" as well and will ask if I want to overwrite that file.
How can I literally copy the "SCOOTE~1.txt" without affecting other long-named files ? Suggestion of external command-line tools is accepted.
Recreation of Problem
c:\Test> > "Scooter - Cosmos.txt" echo File with long name
c:\Test> md SFN
c:\Test> > "SFN\SCOOTE~1.TXT" echo File with short name
c:\Test> dir/s/x
Volume in drive C is OS
Volume Serial Number is BE3C-8BC1
Directory of c:\Test
22/09/2017 08:51 <DIR> .
22/09/2017 08:51 <DIR> ..
22/09/2017 08:50 21 SCOOTE~1.TXT Scooter - Cosmos.txt
22/09/2017 08:51 <DIR> Test
1 File(s) 21 bytes
Directory of c:\Test\SFN
22/09/2017 08:51 <DIR> .
22/09/2017 08:51 <DIR> ..
22/09/2017 08:51 22 SCOOTE~1.TXT
1 File(s) 22 bytes
Total Files Listed:
2 File(s) 43 bytes
5 Dir(s) 104,170,942,464 bytes free
Here the current directory has a file with a long-name of Scooter - Cosmos.txt and a short-name of SCOOTE~1.TXT (Note: the short-name is already in place at this stage). Also, the directory SFN contains a file called SCOOTE~1.TXT – because this name "fits" in the 8.3 format, it does not have a separate short-name.
If we now try to copy this file into the current directory, because the short-/only name of the file being copied matches the short-name of the file already present, it prompts about overwriting:
c:\Test> copy "SFN\SCOOTE~1.TXT"
Overwrite c:\Test\SCOOTE~1.TXT? (Yes/No/All): n
0 file(s) copied.
Single-Instance Fix
As eryksun suggested, you can use the fsutil file setshortname command to fix one-off clashes by changing the short-name of the file in the current directory:
c:\Test> fsutil file setshortname "Scooter - Cosmos.txt" SCOOTE~2.TXT
c:\Test> dir/x
Volume in drive C is OS
Volume Serial Number is BE3C-8BC1
Directory of c:\Test
22/09/2017 09:09 <DIR> .
22/09/2017 09:09 <DIR> ..
22/09/2017 08:50 21 SCOOTE~2.TXT Scooter - Cosmos.txt
22/09/2017 08:51 <DIR> SFN
1 File(s) 21 bytes
3 Dir(s) 104,168,501,248 bytes free
c:\Test> copy "SFN\SCOOTE~1.TXT"
1 file(s) copied.
c:\Test> dir/x
Volume in drive C is OS
Volume Serial Number is BE3C-8BC1
Directory of c:\Test
22/09/2017 09:09 <DIR> .
22/09/2017 09:09 <DIR> ..
22/09/2017 08:50 21 SCOOTE~2.TXT Scooter - Cosmos.txt
22/09/2017 08:51 22 SCOOTE~1.TXT
22/09/2017 08:51 <DIR> SFN
2 File(s) 43 bytes
3 Dir(s) 104,168,464,384 bytes free
Here we can see that the short-name of Scooter - Cosmos.txt has been changed so that it no longer clashes with SCOOTE~1.TXT; the copy proceeds with no warning and both files sit side-by-side in the current directory.
Multiple-Instance Fix
If there are (or could be) several clashes with the files in the target directory, an alternative approach is to use the fsutil 8dot3name strip command to remove the 8.3-format short-names from all files at once:
c:\Test> fsutil 8dot3name strip .
Scanning registry...
Total affected registry keys: 0
Stripping 8dot3 names...
Total files and directories scanned: 2
Total 8dot3 names found: 1
Total 8dot3 names stripped: 1
For details on the operations performed please see the log:
"C:\Users\xxxxxxxx\AppData\Local\Temp\8dot3_removal_log #(GMT 2017-09-22 08-36-00).log"
c:\Test> dir/x
Volume in drive C is OS
Volume Serial Number is BE3C-8BC1
Directory of c:\Test
22/09/2017 09:36 <DIR> .
22/09/2017 09:36 <DIR> ..
22/09/2017 08:50 21 Scooter - Cosmos.txt
22/09/2017 09:33 <DIR> SFN
1 File(s) 21 bytes
3 Dir(s) 104,154,349,568 bytes free
As can be seen, the file Scooter - Cosmos.txt no longer has a short-name, so there is no clash when SCOOTE~1.TXT is copied into the current directory:
c:\Test> copy "SFN\SCOOTE~1.TXT"
1 file(s) copied.
c:\Test> dir/x
Volume in drive C is OS
Volume Serial Number is BE3C-8BC1
Directory of c:\Test
22/09/2017 09:40 <DIR> .
22/09/2017 09:40 <DIR> ..
22/09/2017 08:50 21 Scooter - Cosmos.txt
22/09/2017 08:51 22 SCOOTE~1.TXT
22/09/2017 09:33 <DIR> SFN
2 File(s) 43 bytes
3 Dir(s) 104,151,703,552 bytes free
NOTE: The first stage of this command – Scanning registry... – may take some time as it is looking through the registry for references to the 8.3-format names that are about to be removed. See fsutil 8dot3name strip /? for more details of this command.
Caution (Applies to both methods)
As the help from the fsutil 8dot3name strip /? command says:
This command permanently removes 8dot3 file names from your volume. It
will list the registry keys pointing to the stripped 8dot3names but
will not modify the affected registry keys. Stripping will not be
performed on files with full path names longer than the maximum path
length of 260 characters.
both these commands modify (or remove) the 8.3-format names of selected files. If you have any references to the files concerned (either in the registry, configuration files, or elsewhere in .BAT files etc.) then these references will no longer be valid. Use either solution with due caution.

Source code files location for wrap

I want to encrypt a package code.
For do that, I want to use the wrap command.
So for example I have that package:
wrap_try
and when I'm executing that command:
C:\Users\dp>wrap iname=wrap_try.sql
I'm getting that output:
PL/SQL Wrapper: Release 11.2.0.4.0- 64bit Production on Thu May 11 12:59:50 2017
Copyright (c) 1993, 2009, Oracle. All rights reserved.
PL/SQL Wrapper error: Couldn't open input file wrap_try.sql
So I guess it's can't found my file because i need to give it a full path.
But what is the location of all the package\function definition?
My server is windows.
Thanks a lot.
First extract your procedure source to a file, which in your case is 'wrap_try.sql'. Then run your command on the file.dir,
D:\prog>dir
Volume in drive D is Data
Volume Serial Number is 421D-3389
Directory of D:\prog
05/11/2017 08:04 AM <DIR> .
05/11/2017 08:04 AM <DIR> ..
05/11/2017 08:02 AM 30,609 customer_extract_proc.sql
1 File(s) 30,609 bytes
2 Dir(s) 237,137,584,128 bytes free
D:\prog>wrap iname=customer_extract_proc.sql
PL/SQL Wrapper: Release 11.2.0.4.0- 64bit Production on Thu May 11 08:05:02 2017
Copyright (c) 1993, 2009, Oracle. All rights reserved.
Processing customer_extract_proc.sql to customer_extract_proc.plb
D:\prog>dir
Volume in drive D is Data
Volume Serial Number is 421D-3389
Directory of D:\prog
05/11/2017 08:05 AM <DIR> .
05/11/2017 08:05 AM <DIR> ..
05/11/2017 08:05 AM 5,661 customer_extract_proc.plb
05/11/2017 08:02 AM 30,609 customer_extract_proc.sql
2 File(s) 36,270 bytes
2 Dir(s) 237,137,575,936 bytes free

Bash - What is the best way to save the value of a quantity after the script has terminated?

I am attempting to write a script that changes my desktop wallpaper to the next picture in my ~\Picture\Wallpapers directory. I have already created a script, change_wallpaper, which can change my desktop background to any given picture.
My plan was to list all the pictures in ~\Picture\Wallpapers as an array, find the index i of the current wallpaper, and apply change_wallpaper to the i+1 element of the array of pictures. My only issue is finding a way to story the index of the current wallpaper. I could create a file which contains this value, but it seems really inelegant to just have a text file with the number 12, for example, saved somewhere in my home directory.
Is there a better way?
I agree with the general consensus of using a file to store the index of the current wallpaper. A slightly more elegant way would be to put a "." (dot) in front of the file name to keep it hidden in the directory where your script is located. Something like:
admin#myHost:/home/admin$ ls -la
total 6200
drwxrwxr-x 4 admin admin 4096 Jul 02 15:41 .
drwxr-xr-x 71 bin bin 4096 Jun 29 12:43 ..
-rw------- 1 admin admin 3939 Jun 29 16:02 .bash_history
-rw-r--r-- 1 admin admin 21 Nov 04 2014 .bashrc
-rwxr-x--x 1 admin admin 259 Oct 13 2014 .profile
-rw------- 1 admin admin 3939 Jun 29 16:02 .wallpaper_index
-rw------- 1 admin admin 3939 Jun 29 16:02 change_wallpaper
There are countless linux and unix applications that do this.

What permissions are required, which allow the volume info to be included with the Windows dir cmd?

I'm trying to figure out what permissions are required that would allow a user's account to see the volume information when they run the dir command in a cmd terminal.
This is what the user is seeing:
C:\Cartridges>dir /al
Volume in drive C has no label.
Volume Serial Number is F903-96F1
Directory of C:\Cartridges
08/10/2011 09:53 AM <JUNCTION> 003-0010-01 [..]
04/08/2011 08:39 AM <JUNCTION> 003-0011-01 [\??\Volume{5ea29886-5bd1-45f6-ba68-abcde1234c4a}\]
07/28/2011 09:19 AM <JUNCTION> 003-0011-05 [..]
08/16/2011 08:40 AM <JUNCTION> 003-0011-06 [..]
09/26/2011 02:46 PM <JUNCTION> 003-0011-16 [..]
11/09/2011 10:56 AM <JUNCTION> 003-0011-17 [..]
11/18/2011 04:57 PM <JUNCTION> 003-0011-18 [..]
0 File(s) 0 bytes
14 Dir(s) 138,044,940,288 bytes free
This is what the domain administrator is seeing:
C:\Cartridges>dir /al
Volume in drive C has no label.
Volume Serial Number is F903-96F1
Directory of C:\Cartridges
08/10/2011 09:53 AM <JUNCTION> 003-0010-01 [\??\Volume{6ef57859-c291-45f6-ae05-abcde1234c4a}\]
04/08/2011 08:39 AM <JUNCTION> 003-0011-01 [\??\Volume{5ea29886-5bd1-45f6-ba68-abcde1234c4a}\]
07/28/2011 09:19 AM <JUNCTION> 003-0011-05 [\??\Volume{bf68b7bc-5969-45f6-8602-abcde1234c4a}\]
08/16/2011 08:40 AM <JUNCTION> 003-0011-06 [\??\Volume{1945d928-a345-45f6-95ec-abcde1234c4a}\]
09/26/2011 02:46 PM <JUNCTION> 003-0011-16 [\??\Volume{1945d9e6-a345-45f6-95ec-abcde1234c4a}\]
11/09/2011 10:56 AM <JUNCTION> 003-0011-17 [\??\Volume{0987dab8-0484-11e1-af7d-abcde1234c4a}\]
11/18/2011 04:57 PM <JUNCTION> 003-0011-18 [\??\Volume{0987df91-0484-11e1-af7d-abcde1234c4a}\]
0 File(s) 0 bytes
14 Dir(s) 138,044,887,040 bytes free
NOTE: This is on a system that's in a AD domain.
I figured this out. This was indeed a permissions problem. Initially we weren't sure if it was a policy issue -OR- something to do with the UAC. In the end we needed to add a group that the user was a member of to the top level directory, C:\Cartridges. The permissions on the group needed to be:
Read & Execute
List folder contents
Read
These seemed to be the minimum set that allowed the Volume strings to be displayed correctly.

What happens when a path has no directory separator?

C:WProgram Files
Anyone knows such kind of location? How is it processed in programmes, the same as \ ?
A path with a drive letter and then a relative path is resolved relative to the current directory for that drive letter.
Windows and MS-DOS systems keep track of the current directory for each drive letter separately.
For example:
G:\>dir c:
Volume in drive C is System
Volume Serial Number is A09A-AD9C
Directory of C:\
06/12/2008 02:44 PM 0 AUTOEXEC.BAT
06/12/2008 02:44 PM 0 CONFIG.SYS
08/25/2008 02:22 PM <DIR> Documents and Settings
12/09/2009 12:45 PM <DIR> Program Files
[snip]
G:\>cd "c:\Program Files"
G:\>dir c:
Volume in drive C is System
Volume Serial Number is A09A-AD9C
Directory of C:\Program Files
12/09/2009 12:45 PM <DIR> .
12/09/2009 12:45 PM <DIR> ..
05/14/2010 11:38 AM <DIR> 7-Zip
12/13/2010 01:49 AM <DIR> Adobe
[snip]
G:\>dir c:Adobe
Volume in drive C is System
Volume Serial Number is A09A-AD9C
Directory of C:\Program Files\Adobe
12/13/2010 01:49 AM <DIR> .
12/13/2010 01:49 AM <DIR> ..
01/25/2010 01:45 AM <DIR> Reader 8.0
12/13/2010 01:49 AM <DIR> Reader 9.0
The path c:Adobe became the same as C:\Program Files\Adobe because that was the current directory for the C drive, even though the current drive was actually the G drive.

Resources