using shutil.move() I accidentally renamed my desktop folder to cat.jpg - windows-7

while messing around with shutil and os modules(working on a tutorial exercise). I accidentally moved my desktop folder to an image format type called cat.jpg which doesn't exist anymore, I wasn't trying to move but I was trying to rename the image using shutil.move() when I forgot to type the image's name after its path .I actually managed to fix it after about an hour of googling I recreated a folder and named it desktop then I restored it using previous versions.However, my question is where did the image(cat.jpg) and the original desktop folder go? I searched the whole computer without finding it. here's my code:
shutil.move("c:\\users\\nate\\desktop","cat.jpg")
which output:
'cat.jpg'

I found the desktop folder in the Python folder and its named desktop.jpg but it's still an actual folder containing all the file that I had .However, when I tried to delete it, I got a message saying that the file is shared in the name cat.jpg and asking me to be sure .so anyways just wanted to tell that so anybody facing the same problem will know where to look and what to do .

Related

Pathway to directory lost in R studio

I am relatively new to R studio, I am attempting to import a .RNK file to run on GSEA. However, the pathway to my working directory is lost and I keep receiving a file, "rt" warning message.
When comparing my working directory with my usual windows explorer file, the files themselves are absent from the working directory.
I have attempted to change the Default text encoding to UTF-8 but this has had no effect. I would be grateful for any suggestions to help with this problem?
That is a very common problem!
You have four options to select the correct file and path! Hope at least one can work well.
Manually without code, you can go to the top and choose Session->Set Working Directory -> Choose Directory... and then select the file.
You can just use the function file. choose() and look for the file on your computer and select it.
You can look for the file path on your computer and write it in R. Look in the local search engine for your computer and search for the file. For example: setwd("~/Desktop/University/Homework")
You can use getwd() in the console to know where the script is working and saving the files and then look for the files there!
PD: the best way to work in R and R-Studio/Posit for me is by creating a project. Doing so, you will have everything related to the script in one folder (new and old files!). It is similar to setwd()but better!

macOS: QFileIconProvider icon(QFileInfo) get icons for non-existent files

I'm trying to implement a file explorer that will display a list of remote files(stored on another network server). And I use QFileIconProvider.icon(QFileInfo) to get the file icon.
The QFileInfo is constructed from a single filename(no path information):
for example: QFileInfo fi("test.jpg");
and that works on both Windows and Linux(I tested it on a Ubuntu machine), but it doesn't work on the macOS. On macOS, I always get the warning
Path given to -[NSWorkspace iconForFile:] is not a full path.
I have checked the solution here: Qt 4.8 - QFileIconProvider, Getting icon for non-existent file (based on extension), but it's for the Windows platform.
I was able to make it work if I created a temporary file on my working directory with the same remote filename. But the temporary needs to be kept. If I deleted the temporary file after calling QFileIconProvider::Icon, I will get the warning above when the QTableView tries to display the QIcon in the UI.
Is there any working solution for my case?
Thanks all.
Since there is no "correctly" solution, I just make a workaround:
Create a temporary file for each file extension, and keep them here, only delete these temporary files when you ensure you don't need them anymore. (I choose to delete them before my app quit.
At least, it works for me.
Thanks!

Changing default program for a file type (workaround)

I would like to specify that images of a certain type (for example, .png) open by default in a program I've written when the file is contained in a certain directory. I've seen by searching (Change Default Program for a specific folder) that this is not possible on Windows 7 or 8.
I am saving these images in this directory myself, so I have some leeway with how I name the files. For example, I could change the filename a bit... perhaps to be example.myprog.png or something similar. Is there a way to set it up so files that match this filename pattern get opened, while other .pngs (in other directories) still open in the default viewer?
I don't really want to name these PNG images example.myprog (i.e., fully change the extension), because when the user is browsing the directory in Windows Explorer, I would like the thumbnail images to still show up. Also, users will be eventually transferring these images to their own machines, where they'll want to use standard image viewers to look at them.
If this is not possible, does anyone have another suggestion for how to tackle this problem?
As you are mentioning that files should be opened in a program that you have written, try to change the code of your program to read files from the specific folder. So, by opening your program from anywhere in your pc, you should be able to open files from specified folder.

NSCocoaErrorDomain error 516 caused by bringing PNG into Xcode

I am trying to import PNG images into Xcode (version 4.6.2) on my Mac. These images were created on a Windows 7 machines, and stored on a NAS box.
In finder, when I drag the images from my NAS box into Xcode I get the following error:
The operation couldn't be completed. (NSCocoaErrorDomain error 516).
Using Get Info on that file, Sharing & Permissions only states that You have custom access.
Ive managed to copy these images onto a folder on my Mac's desktop. Using Get Info on these local images, Sharing & Permissions that My User, Staff and Everybody all have Read & Write permissions. I can make copies of these images on my Mac and I can edit these images on my Mac.
When I try and drag these local images into Xcode, I still get the same NSCocoaErrorDomain 516.
EDIT:
Because I read somewhere that the extended attributes could be causing this error, I have just used a Terminal Window to copy the files using this command:
cp -X button.png button2.png
But again, this gives me the same NSCocoaErrorDomain 516.
EDIT 2:
This is getting really infuriating now. If I rename the files, the Xcode accepts the files with no problem. If I rename the file back to what it was, Xcode kicks out the NSCocoaErrorDomain 516 error again. I could go and rename the hundreds of images and change the references to them in my code, but I would really rather find out the cause of this problem.
Ive been making the images on a Windows machine and importing them into Xcode fine for the last two weeks without problem. Today I do the same thing and suddenly this problem occurs. Nothing has changed to the Windows machine or the NAS box. My Mac has not been updated, nor am I aware of any changes to my Mac.
What am I doing wrong? How can I get these images into Xcode?
From Foundation Constants Reference
NSFileWriteFileExistsError = 516
I think You have folder/file named button.png

how to detect files related to an app on a mac

I am wondering how an application like appzapper can detect the files related to an application?
All ideas are welcome.
Thanks for your help,
Regards,
By looking into the standard locations that usually are used by applications to store preferences (like Library/Preferences/ , Library/Caches, etc., both in your home directory ~/ and under / ) I couldn´t find any file or folder that isn´t using either the applications name (eg. ~/Library/Application Support/Firefox) or it´s bundle identifier (eg. ~/Library/Preferences/org.mozilla.firefox.plist) in its name; so I guess they´re just using that.
In the case of AppZapper you can go ahead and try for any (not currently running) Application to rename the ~/Library/Application Support/AppName folder for example to ~/Library/Application Support/111AppName - AppZapper doesn´t find it anymore. If you change it to ~/Library/Application Support/AppName111 it shows up as a related file.
Out of this you can conclude that there isn´t any magical linkage between a folder full of preferences and it´s associated application that AppZapper is reading out, it´s merely checking for folders starting with the Application´s Name.

Resources