file-management

File and Folder Manipulation in Powershell

不问归期 提交于 2019-12-11 12:05:04
问题 I have a folder of thousands of filenames. All filenames are relative to a user's userID. Some users have multiple files in this folder, so it appends a number onto the end of the name. I.E. susy.txt, susy1.txt, susy2.txt, carl.txt, carl1.txt, etc... What I am trying to do is create a specific folder for each user that has multiple files, and move all associated files into that folder. So I notice there are multiple susy documents. So I want to create a folder named Susy and place susy.txt,

How can I test if a string refers to a file or directory? with regular expressions? in python?

跟風遠走 提交于 2019-12-11 11:35:51
问题 so I'm writting a generic backup application with os module and pickle and far I've tried the code below to see if something is a file or directory (based on its string input and not its physical contents). import os, re def test(path): prog = re.compile("^[-\w,\s]+.[A-Za-z]{3}$") result = prog.match(path) if os.path.isfile(path) or result: print "is file" elif os.path.isdir(path): print "is directory" else: print "I dont know" Problems test("C:/treeOfFunFiles/") is directory test("/beach.jpg

Windows: compare files in folders and delete non existent

↘锁芯ラ 提交于 2019-12-11 05:05:48
问题 I have huge directories + subdirs containing files on Windows. On the windows command line (or through a script) I'd like to compare two folders and delete files from the subfolder that are not in the main folder. In the example below the even numbered files should be deleted from the subfolder. folder: C:\folder1 file1.jpg file3.jpg file4.jpg file7.jpg file9.jpg subfolder: C:\folder1\RAW\ file1.CR2 file2.CR2 file3.CR2 file4.CR2 file5.CR2 file6.CR2 file7.CR2 file8.CR2 file9.CR2 I have tried

command line wisdom for 2 panel file manager user

佐手、 提交于 2019-12-11 04:45:47
问题 Want to upgrade my file management productivity by replacing 2 panel file manager with command line (bash or cygwin). Can commandline give same speed? Please advise a guru way of how to do e.g. copy of some file in directory A to the directory B. Is it heavy use of pushd/popd? Or creation of links to most often used directories? What are the best practices and a day-to-day routine to manage files of a command line master? 回答1: Can commandline give same speed? My experience is that commandline

GetFinalPathNameByHandle() result without prepended '\\?\'

╄→尐↘猪︶ㄣ 提交于 2019-12-10 19:27:42
问题 Here is my code snippet: char existingTarget[MAX_PATH]; HANDLE hFile = CreateFile(linkPath.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE != hFile) { GetFinalPathNameByHandle(hFile, existingTarget, MAX_PATH, FILE_NAME_OPENED); CloseHandle(hFile); } However, existingTarget is coming out to be \\?\C:\mydir\etc . How can I get it to return just C:\mydir\etc ? Note : I don't want to check for the string \\?\ and just memmove it,

List files and directories with Jtree and File in Java

£可爱£侵袭症+ 提交于 2019-12-10 10:56:37
问题 I want to create a very very simple file manager with JTree, but I only saw a very hard code and I want to create this script very clean and simple. Can you help me? How do I List the directories of my computer in JTree? 回答1: I wrote the simplest example of a file browser I could think of. It lists all of the directories and files on the C: drive on a Windows computer. Here's the result. And here's the code. I put everything together in one class to make it easier to paste here. You should

Change file owner in Windows

怎甘沉沦 提交于 2019-12-09 17:46:37
问题 Is there an API in Windows similar to Linux's chown? 回答1: Taken from here: http://www.perlmonks.org/?node_id=70562 // #includes omitted for the sake of sanity HANDLE token; char *filename = "somefile.txt"; char *newuser = "someuser"; DWORD len; PSECURITY_DESCRIPTOR security = NULL; PSID sidPtr = NULL; int retValue = 1; // Get the privileges you need if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token)) { SetPrivilege(token, "SeTakeOwnershipPrivilege", 1); SetPrivilege

Using git to track only some of a Unity project

微笑、不失礼 提交于 2019-12-08 14:03:49
问题 I've been using git to work on a Unity project, but I've found I don't really want to check the the whole project into source control all the time. I have a bunch of plugins downloaded that I expect to delete later and I don't want to bring them into my git history. Are there any files in Unity that I need to keep checked in or am ok to just version the stuff I'm working on. I'm still getting the hang of git so this may be as much about version control best practices as it is about Unity. For

Rename all files in folder to uppercase with batch

拜拜、爱过 提交于 2019-12-07 05:14:57
问题 Is there a way to rename all files in a specific folder to uppercase with batch file? I found this code. But it renames files to lowercase. How to modify it to rename to uppercase instead? for /f "Tokens=*" %f in ('dir /l/b/a-d') do (rename "%f" "%f") 回答1: @echo off setlocal enableDelayedExpansion pushd c:\some_dir for %%f in (*) do ( set "filename=%%~f" for %%A in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do ( set "filename=!filename:%%A=%%A!" ) ren "%%f" "!filename!" >nul 2>&1 )

List files and directories with Jtree and File in Java

僤鯓⒐⒋嵵緔 提交于 2019-12-06 10:55:54
I want to create a very very simple file manager with JTree, but I only saw a very hard code and I want to create this script very clean and simple. Can you help me? How do I List the directories of my computer in JTree? I wrote the simplest example of a file browser I could think of. It lists all of the directories and files on the C: drive on a Windows computer. Here's the result. And here's the code. I put everything together in one class to make it easier to paste here. You should separate the classes. package com.ggl.testing; import java.io.File; import javax.swing.JFrame; import javax